From 5c5a44876b311a704fc5bf7a21e4b773ec28c4ab Mon Sep 17 00:00:00 2001 From: Joel Thomas Date: Tue, 19 May 2026 14:37:46 +0530 Subject: [PATCH] Implement Logout functionality CUS002: Logout 1. Connected Controller::logout() with AuthenticationManagementService logout logic. 2. Added logout implementation in AuthenticationManagementService to clear the authenticated user session. 3. Added logout handling in CustomerMenu to invoke controller logout when the user selects the logout option. 4. Added authentication service dependency in Controller for logout support. Logout functionality validation Precondition: 1. System is running. 2. A registered user exists in the data store. 3. User is logged in and customer menu is active. Steps: 1. Launch the application and log in with valid credentials. - Verify that access is granted and customer menu is displayed. 2. Select the Logout option from the customer menu. - Verify that the logout operation is triggered immediately. 3. Complete the logout operation. - Verify that the authenticated user session is cleared. 4. After logout completes. - Verify that the user is redirected to the login menu. Sreeja Reghukumar, please review --- .../Trenser.VehicleServiceSystem/controllers/Controller.cpp | 1 + .../Trenser.VehicleServiceSystem/controllers/Controller.h | 3 +++ .../services/AuthenticationManagementService.cpp | 5 +++++ .../Trenser.VehicleServiceSystem/views/CustomerMenu.cpp | 1 + 4 files changed, 10 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..0333e80 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..c128d26 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; +} diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 047f471..2e5fc75 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -33,6 +33,7 @@ bool CustomerMenu::handleOperation(int choice) void CustomerMenu::logout() { + m_controller.logout(); } void CustomerMenu::changePassword()