Merge branch 'feature-admin-management-adm005' into feature-admin-management
This commit is contained in:
@@ -13,6 +13,7 @@ void Controller::logout()
|
||||
|
||||
void Controller::changePassword(const std::string& newPassword)
|
||||
{
|
||||
m_authenticationManagementService.changePassword(newPassword);
|
||||
}
|
||||
|
||||
void Controller::createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
||||
|
||||
+11
-1
@@ -1,8 +1,18 @@
|
||||
#include "AuthenticationManagementService.h"
|
||||
#include "User.h"
|
||||
|
||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||
|
||||
void AuthenticationManagementService::logout()
|
||||
{
|
||||
m_authenticatedUser = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AuthenticationManagementService::changePassword(const std::string& newPassword)
|
||||
{
|
||||
if (m_authenticatedUser == nullptr)
|
||||
{
|
||||
throw std::runtime_error("There is no user currently logged in!");
|
||||
}
|
||||
m_authenticatedUser->setPassword(newPassword);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,23 @@ void AdminMenu::logout()
|
||||
|
||||
void AdminMenu::changePassword()
|
||||
{
|
||||
std::string newPassword;
|
||||
while (true)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Enter new password: ";
|
||||
util::read(newPassword);
|
||||
if (!util::isPasswordValid(newPassword))
|
||||
{
|
||||
std::cout << "Error: Password is not strong enough!\n";
|
||||
util::pressEnter();
|
||||
continue;
|
||||
}
|
||||
m_controller.changePassword(newPassword);
|
||||
std::cout << "Password changed successfully\n";
|
||||
util::pressEnter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AdminMenu::viewStockLevels()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "TechnicianMenu.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "Validator.h"
|
||||
|
||||
void TechnicianMenu::showMenu()
|
||||
{
|
||||
@@ -42,4 +43,25 @@ void TechnicianMenu::viewNotifications()
|
||||
void TechnicianMenu::logout()
|
||||
{
|
||||
m_controller.logout();
|
||||
}
|
||||
|
||||
void TechnicianMenu::changePassword()
|
||||
{
|
||||
std::string newPassword;
|
||||
while (true)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Enter new password: ";
|
||||
util::read(newPassword);
|
||||
if (!util::isPasswordValid(newPassword))
|
||||
{
|
||||
std::cout << "Error: Password is not strong enough!\n";
|
||||
util::pressEnter();
|
||||
continue;
|
||||
}
|
||||
m_controller.changePassword(newPassword);
|
||||
std::cout << "Password changed successfully\n";
|
||||
util::pressEnter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,5 @@ public:
|
||||
void completeJob();
|
||||
void viewNotifications();
|
||||
void logout();
|
||||
void changePassword();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user