Merged PR 896: UserStory AUTH003 Logout

Related work items: #932, #935, #936
This commit is contained in:
Jissin Mathew
2026-04-06 13:59:44 +05:30
committed by Joel Thomas
4 changed files with 18 additions and 1 deletions
@@ -8,6 +8,7 @@ AuthenticationContext ZenvyController::login(const std::string& email, const std
void ZenvyController::logout()
{
m_authenticationManagementService->logout();
}
void ZenvyController::changePassword(const std::string& password) const
@@ -24,4 +24,10 @@ void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticated
employeeMap& DataStore::getEmployees()
{
return m_employees;
}
}
std::shared_ptr<Employee>& DataStore::getAuthenticatedUser()
{
return m_authenticatedEmployee;
}
@@ -36,6 +36,7 @@ public:
DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees();
std::shared_ptr<Employee>& getAuthenticatedUser();
logMap& getLogs();
std::shared_ptr<Employee>& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
@@ -59,3 +59,12 @@ void AuthenticationManagementService::changePassword(const std::string& password
throw std::runtime_error("User not found");
}
}
void AuthenticationManagementService::logout() {
if (m_dataStore.getAuthenticatedUser()) {
m_dataStore.getAuthenticatedUser() = nullptr;
}
else {
throw std::runtime_error("No user currently logged In...");
}
}