Implement Logout functionality
<UserStory> ADM004: Logout </UserStory>
<Changes>
1. Added AuthenticationManagementService::logout to clear authenticated user session.
2. Integrated logout handling in Controller::logout to delegate session termination.
3. Updated AdminMenu::logout and TechnicianMenu::logout to call Controller::logout for consistent session management.
4. Extended TechnicianMenu.h with logout method declaration.
5. Ensured session termination returns control to main menu after logout.
</Changes>
<Test>
Precondition:
1. User is logged into the system (Admin or Technician).
2. AuthenticationManagementService maintains active session.
3. Controller is connected to AuthenticationManagementService.
Steps:
1. Navigate to Admin or Technician Menu.
2. Select "Logout" option.
- Verify that AuthenticationManagementService::logout clears authenticated user.
3. Session is terminated.
- Verify that system confirms logout and invalidates session.
4. Console returns to main menu.
- Verify that user is redirected to main menu and must log in again to continue.
</Test>
<Review>
Sreeja Reghukumar
</Review>
This commit is contained in:
@@ -7,6 +7,7 @@ bool Controller::login(const std::string& username, const std::string& password)
|
||||
|
||||
void Controller::logout()
|
||||
{
|
||||
m_authenticationManagementService.logout();
|
||||
}
|
||||
|
||||
void Controller::changePassword(const std::string& newPassword)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Map.h"
|
||||
#include <string>
|
||||
#include "Enums.h"
|
||||
#include "AuthenticationManagementService.h"
|
||||
|
||||
class Service;
|
||||
class ComboPackage;
|
||||
@@ -14,6 +15,8 @@ class Notification;
|
||||
|
||||
class Controller
|
||||
{
|
||||
private:
|
||||
AuthenticationManagementService m_authenticationManagementService;
|
||||
public:
|
||||
bool login(const std::string& username, const std::string& password);
|
||||
void logout();
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
#include "AuthenticationManagementService.h"
|
||||
|
||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||
|
||||
void AuthenticationManagementService::logout()
|
||||
{
|
||||
m_authenticatedUser = nullptr;
|
||||
}
|
||||
@@ -34,6 +34,7 @@ bool AdminMenu::handleOperation(int choice)
|
||||
|
||||
void AdminMenu::logout()
|
||||
{
|
||||
m_controller.logout();
|
||||
}
|
||||
|
||||
void AdminMenu::changePassword()
|
||||
|
||||
@@ -38,3 +38,8 @@ void TechnicianMenu::completeJob()
|
||||
void TechnicianMenu::viewNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void TechnicianMenu::logout()
|
||||
{
|
||||
m_controller.logout();
|
||||
}
|
||||
@@ -10,4 +10,5 @@ public:
|
||||
void showMenu();
|
||||
void completeJob();
|
||||
void viewNotifications();
|
||||
void logout();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user