Add changePassword method in controller and authenticated user accessor
<UserStory> AUTH004 : Change Password </UserStory>
<Changes>
- Added changePassword method in ZenvyController to move to AuthenticationManagementService
- Declared changePassword in ZenvyController.h
- Introduced getAuthenticatedUser() in DataStore for accessing authenticated employee
- Updated DataStore.h with getAuthenticatedUser() method
- Prepared AuthenticationManagementService.cpp for password change implementation
</Changes>
<Review>
Smitha Mohan
</Review>
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
|
//Authentication
|
||||||
AuthenticationContext login(const std::string& email, const std::string& password);
|
AuthenticationContext login(const std::string& email, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
|
void changePassword(const std::string&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ logMap& DataStore::getLogs()
|
|||||||
return m_logs;
|
return m_logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
|
||||||
|
{
|
||||||
|
return m_authenticatedEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
|
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
|
||||||
{
|
{
|
||||||
m_authenticatedEmployee = authenticatedEmployee;
|
m_authenticatedEmployee = authenticatedEmployee;
|
||||||
|
|||||||
@@ -37,5 +37,6 @@ public:
|
|||||||
DataStore& operator=(DataStore&&) = delete;
|
DataStore& operator=(DataStore&&) = delete;
|
||||||
employeeMap& getEmployees();
|
employeeMap& getEmployees();
|
||||||
logMap& getLogs();
|
logMap& getLogs();
|
||||||
|
std::shared_ptr<Employee>& getAuthenticatedEmployee();
|
||||||
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
|
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);
|
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 <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <stdexcept>
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
|
|
||||||
@@ -13,6 +14,6 @@ public:
|
|||||||
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {};
|
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||||
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> login(const std::string& username, const std::string& password);
|
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> login(const std::string& username, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
void changePassword();
|
void changePassword(std::string);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user