Merged PR 895: UserStory AUTH004 Change Password
Related work items: #936
This commit is contained in:
@@ -10,6 +10,7 @@ void ZenvyController::logout()
|
||||
{
|
||||
}
|
||||
|
||||
void AuthenticationManagementService::changePassword()
|
||||
void ZenvyController::changePassword(const std::string& password) const
|
||||
{
|
||||
m_authenticationManagementService->changePassword(password);
|
||||
}
|
||||
|
||||
@@ -44,5 +44,7 @@ public:
|
||||
//Authentication
|
||||
AuthenticationContext login(const std::string& email, const std::string& password);
|
||||
void logout();
|
||||
void changePassword(const std::string&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ logMap& DataStore::getLogs()
|
||||
return m_logs;
|
||||
}
|
||||
|
||||
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
|
||||
{
|
||||
return m_authenticatedEmployee;
|
||||
}
|
||||
|
||||
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
|
||||
{
|
||||
m_authenticatedEmployee = authenticatedEmployee;
|
||||
|
||||
@@ -37,5 +37,6 @@ public:
|
||||
DataStore& operator=(DataStore&&) = delete;
|
||||
employeeMap& getEmployees();
|
||||
logMap& getLogs();
|
||||
std::shared_ptr<Employee>& getAuthenticatedEmployee();
|
||||
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
|
||||
};
|
||||
@@ -46,3 +46,16 @@ std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation>
|
||||
}
|
||||
return std::make_tuple(loginStatus, employeeType, employeeDesignation);
|
||||
}
|
||||
|
||||
void AuthenticationManagementService::changePassword(const std::string& password)
|
||||
{
|
||||
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedUser();
|
||||
if (authenticatedUser)
|
||||
{
|
||||
authenticatedUser->setEmployeePassword(password);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("User not found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
#include "DataStore.h"
|
||||
#include "Enums.h"
|
||||
|
||||
@@ -13,6 +14,6 @@ public:
|
||||
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> login(const std::string& username, const std::string& password);
|
||||
void logout();
|
||||
void changePassword();
|
||||
void changePassword(std::string);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user