Add logout functionality in controller and datastore access
<UserStory> AUTH003: Logout User </UserStory> <Changes> - Added logout() method in ZenvyController and AuthenticationManagementService - Implemented logout handling in AuthenticationManagementService </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -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...");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user