From df769a7528bd0e4dee2ad7a4f4b0c549e2270dd1 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Wed, 20 May 2026 20:04:25 +0530 Subject: [PATCH] Implement Logout functionality ADM004: Logout 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. 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. Sreeja Reghukumar --- .../Trenser.VehicleServiceSystem/controllers/Controller.cpp | 1 + .../Trenser.VehicleServiceSystem/controllers/Controller.h | 3 +++ .../services/AuthenticationManagementService.cpp | 5 +++++ .../Trenser.VehicleServiceSystem/views/AdminMenu.cpp | 1 + .../Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp | 5 +++++ .../Trenser.VehicleServiceSystem/views/TechnicianMenu.h | 1 + 6 files changed, 16 insertions(+) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp index d536e8a..06fe460 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.cpp @@ -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) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h index 3aabb58..80eefdc 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/controllers/Controller.h @@ -2,6 +2,7 @@ #include "Map.h" #include #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(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index ca07fee..cf79ab5 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -1,3 +1,8 @@ #include "AuthenticationManagementService.h" User* AuthenticationManagementService::m_authenticatedUser = nullptr; + +void AuthenticationManagementService::logout() +{ + m_authenticatedUser = nullptr; +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 0432f3c..d61c12f 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -34,6 +34,7 @@ bool AdminMenu::handleOperation(int choice) void AdminMenu::logout() { + m_controller.logout(); } void AdminMenu::changePassword() diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index d6c4d57..e087cb4 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -38,3 +38,8 @@ void TechnicianMenu::completeJob() void TechnicianMenu::viewNotifications() { } + +void TechnicianMenu::logout() +{ + m_controller.logout(); +} \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h index c366d9b..53449af 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h @@ -10,4 +10,5 @@ public: void showMenu(); void completeJob(); void viewNotifications(); + void logout(); };