Merge branch 'feature-customer-management-cus003' into feature-customer-management
This commit is contained in:
@@ -12,6 +12,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,3 +1,4 @@
|
|||||||
|
#include <stdexcept>
|
||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
|
|
||||||
@@ -32,3 +33,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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CustomerMenu.h"
|
#include "CustomerMenu.h"
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
|
#include "Validator.h"
|
||||||
|
|
||||||
void CustomerMenu::showMenu()
|
void CustomerMenu::showMenu()
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,19 @@ void CustomerMenu::logout()
|
|||||||
|
|
||||||
void CustomerMenu::changePassword()
|
void CustomerMenu::changePassword()
|
||||||
{
|
{
|
||||||
|
std::string newPassword;
|
||||||
|
util::clear();
|
||||||
|
std::cout << "Enter new password: ";
|
||||||
|
util::read(newPassword);
|
||||||
|
m_controller.changePassword(newPassword);
|
||||||
|
if (!util::isPasswordValid(newPassword))
|
||||||
|
{
|
||||||
|
std::cout << "Error: Password is not strong enough!";
|
||||||
|
util::pressEnter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << "Password changed successfully";
|
||||||
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomerMenu::updateDetails()
|
void CustomerMenu::updateDetails()
|
||||||
|
|||||||
Reference in New Issue
Block a user