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)
|
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)
|
void Controller::createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
||||||
|
|||||||
+10
@@ -1,4 +1,5 @@
|
|||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
|
#include "User.h"
|
||||||
|
|
||||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||||
|
|
||||||
@@ -6,3 +7,12 @@ void AuthenticationManagementService::logout()
|
|||||||
{
|
{
|
||||||
m_authenticatedUser = nullptr;
|
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()
|
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()
|
void AdminMenu::viewStockLevels()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "TechnicianMenu.h"
|
#include "TechnicianMenu.h"
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
|
#include "Validator.h"
|
||||||
|
|
||||||
void TechnicianMenu::showMenu()
|
void TechnicianMenu::showMenu()
|
||||||
{
|
{
|
||||||
@@ -43,3 +44,24 @@ void TechnicianMenu::logout()
|
|||||||
{
|
{
|
||||||
m_controller.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 completeJob();
|
||||||
void viewNotifications();
|
void viewNotifications();
|
||||||
void logout();
|
void logout();
|
||||||
|
void changePassword();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user