Implement Login Functionality

<UserStory> ADM003: Login </UserStory>

<Changes>
    1. Added credential input handling in UserInterface::login with username and password prompts.
    2. Integrated Controller::login to validate credentials and retrieve authenticated user.
    3. Implemented role-based menu navigation: Admin → AdminMenu, Technician → TechnicianMenu, Customer → CustomerMenu.
    4. Added error handling for invalid credentials and unknown user types with clear feedback messages.
    5. Included util::clear for screen refresh and structured output formatting during login.
</Changes>

<Test>

  Precondition:
  1. Valid user accounts exist in the system (Admin, Technician, Customer).
  2. Controller is connected to UserManagementService for authentication.
  3. UserInterface is initialized with role-specific menus.

  Steps:
  1. Launch UserInterface and select "Login".
  2. Enter incorrect username or password.
    - Verify that system displays "Error: Invalid Username or Password".
  3. Enter valid admin credentials.
    - Verify that AdminMenu is displayed successfully.
  4. Enter valid technician or customer credentials.
    - Verify that TechnicianMenu or CustomerMenu is displayed accordingly.
</Test>

<Review>
Sreeja Reghukumar
</Review>
This commit is contained in:
Avinash Rajesh
2026-05-20 19:42:45 +05:30
parent 56c5c2dc70
commit fa08d4a90f
@@ -1,6 +1,7 @@
#include "UserInterface.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "User.h"
void UserInterface::run()
{
@@ -48,7 +49,38 @@ bool UserInterface::handleOperation(int choice)
void UserInterface::login()
{
std::string username, password;
util::clear();
std::cout << "Enter username: ";
util::read(username);
std::cout << "Enter password: ";
util::read(password);
if (m_controller.login(username, password))
{
const User* authenticatedUser = m_controller.getAuthenticatedUser();
if (authenticatedUser != nullptr)
{
switch (authenticatedUser->getUserType())
{
case util::UserType::ADMIN:
m_adminMenu.showMenu();
break;
case util::UserType::TECHNICIAN:
m_technicianMenu.showMenu();
break;
case util::UserType::CUSTOMER:
m_customerMenu.showMenu();
break;
default:
std::cout << "\nError: Unknown user type";
break;
}
}
}
else
{
std::cout << "\nError: Invalid Username or Password";
}
}
void UserInterface::registerCustomer()