Implement Logout functionality

<UserStory> CUS002: Logout</UserStory>

<Changes>
    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.
</Changes>

<Test>

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.

</Test>

<Review>
Sreeja Reghukumar, please review
</Review>
This commit is contained in:
2026-05-19 14:37:46 +05:30
parent 56c5c2dc70
commit 5c5a44876b
4 changed files with 10 additions and 0 deletions
@@ -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();
@@ -1,3 +1,8 @@
#include "AuthenticationManagementService.h"
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
void AuthenticationManagementService::logout()
{
m_authenticatedUser = nullptr;
}
@@ -33,6 +33,7 @@ bool CustomerMenu::handleOperation(int choice)
void CustomerMenu::logout()
{
m_controller.logout();
}
void CustomerMenu::changePassword()