Merged PR 897: UserStory AUTH002 Reset Initial Password
Related work items: #933
This commit is contained in:
@@ -174,9 +174,6 @@
|
|||||||
<ClCompile Include="views\ITExecutiveMenu.cpp">
|
<ClCompile Include="views\ITExecutiveMenu.cpp">
|
||||||
<Filter>Views</Filter>
|
<Filter>Views</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="views\MainMenu.cpp">
|
|
||||||
<Filter>Views</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="views\TalentExecutiveMenu.cpp">
|
<ClCompile Include="views\TalentExecutiveMenu.cpp">
|
||||||
<Filter>Views</Filter>
|
<Filter>Views</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -192,6 +189,9 @@
|
|||||||
<ClCompile Include="models\Faq.cpp">
|
<ClCompile Include="models\Faq.cpp">
|
||||||
<Filter>Models</Filter>
|
<Filter>Models</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="services\ApplicationConfig.cpp">
|
||||||
|
<Filter>Services</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="services\AuthenticationManagementService.h">
|
<ClInclude Include="services\AuthenticationManagementService.h">
|
||||||
@@ -320,12 +320,6 @@
|
|||||||
<ClInclude Include="views\ITExecutiveMenu.h">
|
<ClInclude Include="views\ITExecutiveMenu.h">
|
||||||
<Filter>Views</Filter>
|
<Filter>Views</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="views\MainMenu.h">
|
|
||||||
<Filter>Views</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="views\Menu.h">
|
|
||||||
<Filter>Views</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="views\TalentExecutiveMenu.h">
|
<ClInclude Include="views\TalentExecutiveMenu.h">
|
||||||
<Filter>Views</Filter>
|
<Filter>Views</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -341,6 +335,9 @@
|
|||||||
<ClInclude Include="models\Faq.h">
|
<ClInclude Include="models\Faq.h">
|
||||||
<Filter>Models</Filter>
|
<Filter>Models</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="services\ApplicationConfig.h">
|
||||||
|
<Filter>Services</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="models\Employee.h">
|
<ClInclude Include="models\Employee.h">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ void ZenvyController::logout()
|
|||||||
m_authenticationManagementService->logout();
|
m_authenticationManagementService->logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZenvyController::changePassword(const std::string& password) const
|
void ZenvyController::changePassword(const std::string& password)
|
||||||
{
|
{
|
||||||
m_authenticationManagementService->changePassword(password);
|
m_authenticationManagementService->changePassword(password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,5 @@ 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;
|
void changePassword(const std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,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(std::string);
|
void changePassword(const std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
#include <string>
|
||||||
|
#include <cctype>
|
||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
#include "ApplicationConfig.h"
|
||||||
|
|
||||||
bool util::isPhoneNumberValid(const std::string& phoneNumber) {
|
bool util::isPhoneNumberValid(const std::string& phoneNumber) {
|
||||||
if (phoneNumber.size() != 10)
|
if (phoneNumber.size() != 10)
|
||||||
@@ -26,3 +29,43 @@ bool util::isEmailValid(const std::string& email) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool util::isPasswordValid(const std::string& password)
|
||||||
|
{
|
||||||
|
if (password == Config::DEFAULT_PASSWORD)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (password.length() < 8)
|
||||||
|
return false;
|
||||||
|
bool hasUpper = false;
|
||||||
|
bool hasLower = false;
|
||||||
|
bool hasDigit = false;
|
||||||
|
bool hasSpecial = false;
|
||||||
|
|
||||||
|
for (char character : password)
|
||||||
|
{
|
||||||
|
if (std::isspace(static_cast<unsigned char>(character)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (std::isupper(static_cast<unsigned char>(character)))
|
||||||
|
{
|
||||||
|
hasUpper = true;
|
||||||
|
}
|
||||||
|
else if (std::islower(static_cast<unsigned char>(character)))
|
||||||
|
{
|
||||||
|
hasLower = true;
|
||||||
|
}
|
||||||
|
else if (std::isdigit(static_cast<unsigned char>(character)))
|
||||||
|
{
|
||||||
|
hasDigit = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hasSpecial = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasUpper && hasLower && hasDigit && hasSpecial;
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ namespace util
|
|||||||
{
|
{
|
||||||
bool isPhoneNumberValid(const std::string&);
|
bool isPhoneNumberValid(const std::string&);
|
||||||
bool isEmailValid(const std::string&);
|
bool isEmailValid(const std::string&);
|
||||||
|
bool isPasswordValid(const std::string&);
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "ZenvyController.h"
|
#include "ZenvyController.h"
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
|
#include "Validator.h"
|
||||||
|
|
||||||
void UserInterface::run()
|
void UserInterface::run()
|
||||||
{
|
{
|
||||||
@@ -82,11 +83,20 @@ void UserInterface::login()
|
|||||||
if (loginStatus == Enums::LoginStatus::FIRST_LOGIN)
|
if (loginStatus == Enums::LoginStatus::FIRST_LOGIN)
|
||||||
{
|
{
|
||||||
util::clear();
|
util::clear();
|
||||||
std::cout
|
std::cout << "Warning: You're using the default password!\n"
|
||||||
<< "Warning: You're using the default password!\n"
|
|
||||||
<< "Please change it.\n";
|
<< "Please change it.\n";
|
||||||
// TODO: Password reset flow (to be implemented)
|
std::cout << "Enter new password: \n";
|
||||||
|
util::read(password);
|
||||||
|
if (util::isPasswordValid(password))
|
||||||
|
{
|
||||||
|
m_controller->changePassword(password);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "\nInvalid Password";
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
util::clear();
|
util::clear();
|
||||||
// Route to appropriate menu
|
// Route to appropriate menu
|
||||||
|
|||||||
Reference in New Issue
Block a user