Merged PR 899: SRS01 Authentication

Related work items: #930, #932, #933, #935, #936
This commit is contained in:
2026-04-06 17:50:32 +05:30
42 changed files with 1341 additions and 43 deletions
@@ -0,0 +1,7 @@
#include "UserInterface.h"
int main()
{
UserInterface userInterFace;
userInterFace.run();
return 0;
}
@@ -102,7 +102,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)controllers;$(ProjectDir)services;$(ProjectDir)utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)models;$(ProjectDir)controllers;$(ProjectDir)services;$(ProjectDir)utilities;$(ProjectDir)factories;$(ProjectDir)datastores;$(ProjectDir)views;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -131,6 +131,7 @@
<ClCompile Include="models\Attendance.cpp" />
<ClCompile Include="models\Booking.cpp" />
<ClCompile Include="models\Candidate.cpp" />
<ClCompile Include="models\Faq.cpp" />
<ClCompile Include="models\FinanceExecutive.cpp" />
<ClCompile Include="models\GeneralEmployee.cpp" />
<ClCompile Include="models\ITExecutive.cpp" />
@@ -145,6 +146,7 @@
<ClCompile Include="models\Team.cpp" />
<ClCompile Include="models\TeamExecutive.cpp" />
<ClCompile Include="models\Ticket.cpp" />
<ClCompile Include="services\ApplicationConfig.cpp" />
<ClCompile Include="services\AttendanceManagementService.cpp" />
<ClCompile Include="services\AuthenticationManagementService.cpp" />
<ClCompile Include="services\BookingManagementService.cpp" />
@@ -165,6 +167,15 @@
<ClCompile Include="utilities\OutputHelper.cpp" />
<ClCompile Include="utilities\Timestamp.cpp" />
<ClCompile Include="utilities\Validator.cpp" />
<ClCompile Include="views\AdminMenu.cpp" />
<ClCompile Include="views\EmployeeMenu.cpp" />
<ClCompile Include="views\FinanceExecutiveMenu.cpp" />
<ClCompile Include="views\HRManagerMenu.cpp" />
<ClCompile Include="views\ITExecutiveMenu.cpp" />
<ClCompile Include="views\TalentExecutiveMenu.cpp" />
<ClCompile Include="views\TeamExecutiveMenu.cpp" />
<ClCompile Include="views\TeamLeadMenu.cpp" />
<ClCompile Include="views\UserInterface.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="controllers\ZenvyController.h" />
@@ -174,6 +185,7 @@
<ClInclude Include="models\Attendance.h" />
<ClInclude Include="models\Booking.h" />
<ClInclude Include="models\Candidate.h" />
<ClInclude Include="models\Faq.h" />
<ClInclude Include="models\FinanceExecutive.h" />
<ClInclude Include="models\GeneralEmployee.h" />
<ClInclude Include="models\ITExecutive.h" />
@@ -188,6 +200,7 @@
<ClInclude Include="models\Team.h" />
<ClInclude Include="models\TeamExecutive.h" />
<ClInclude Include="models\Ticket.h" />
<ClInclude Include="services\ApplicationConfig.h" />
<ClInclude Include="services\AttendanceManagementService.h" />
<ClInclude Include="services\AuthenticationManagementService.h" />
<ClInclude Include="services\BookingManagementService.h" />
@@ -204,6 +217,15 @@
<ClInclude Include="utilities\OutputHelper.h" />
<ClInclude Include="utilities\Timestamp.h" />
<ClInclude Include="utilities\Validator.h" />
<ClInclude Include="views\AdminMenu.h" />
<ClInclude Include="views\EmployeeMenu.h" />
<ClInclude Include="views\FinanceExecutiveMenu.h" />
<ClInclude Include="views\HRManagerMenu.h" />
<ClInclude Include="views\ITExecutiveMenu.h" />
<ClInclude Include="views\TalentExecutiveMenu.h" />
<ClInclude Include="views\TeamExecutiveMenu.h" />
<ClInclude Include="views\TeamLeadMenu.h" />
<ClInclude Include="views\UserInterface.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="models\Admin.h" />
@@ -5,10 +5,6 @@
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
@@ -31,11 +27,15 @@
<Filter Include="DataStores">
<UniqueIdentifier>{eb93b9d1-08eb-48aa-be2a-e17085ce27bd}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Views">
<UniqueIdentifier>{84db0710-2b0f-48bc-a72f-bd10c29954fc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Trenser.Zenvy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="services\AuthenticationManagementService.cpp">
<Filter>Services</Filter>
</ClCompile>
@@ -156,6 +156,42 @@
<ClCompile Include="models\Log.cpp">
<Filter>Models</Filter>
</ClCompile>
<ClCompile Include="Trenser.Zenvy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="views\AdminMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\EmployeeMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\FinanceExecutiveMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\HRManagerMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\ITExecutiveMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\TalentExecutiveMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\TeamExecutiveMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\TeamLeadMenu.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="views\UserInterface.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="models\Faq.cpp">
<Filter>Models</Filter>
</ClCompile>
<ClCompile Include="services\ApplicationConfig.cpp">
<Filter>Services</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="services\AuthenticationManagementService.h">
@@ -269,6 +305,39 @@
<ClInclude Include="models\Log.h">
<Filter>Models</Filter>
</ClInclude>
<ClInclude Include="views\AdminMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\EmployeeMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\FinanceExecutiveMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\HRManagerMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\ITExecutiveMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\TalentExecutiveMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\TeamExecutiveMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\TeamLeadMenu.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="views\UserInterface.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="models\Faq.h">
<Filter>Models</Filter>
</ClInclude>
<ClInclude Include="services\ApplicationConfig.h">
<Filter>Services</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="models\Employee.h">
@@ -1 +1,17 @@
#include "ZenvyController.h"
//Authentication
AuthenticationContext ZenvyController::login(const std::string& email, const std::string& password)
{
return m_authenticationManagementService->login(email, password);
}
void ZenvyController::logout()
{
m_authenticationManagementService->logout();
}
void ZenvyController::changePassword(const std::string& password)
{
m_authenticationManagementService->changePassword(password);
}
@@ -1,5 +1,48 @@
#pragma once
#include <memory>
#include <utility>
#include "AuthenticationManagementService.h"
#include "AttendanceManagementService.h"
#include "BookingManagementService.h"
#include "EmployeeManagememtService.h"
#include "LeaveManagementService.h"
#include "NotificationManagementService.h"
#include "PayslipManagementService.h"
#include "TalentAcquisitionManagementService.h"
#include "TeamManagementService.h"
#include "TicketManagementService.h"
#include "Enums.h"
using AuthenticationContext = std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation>;
class ZenvyController
{
private:
std::shared_ptr<AuthenticationManagementService> m_authenticationManagementService;
std::shared_ptr<AttendanceManagementService> m_attendanceManagementService;
std::shared_ptr<BookingManagementService> m_bookingManagementService;
std::shared_ptr<EmployeeManagememtService> m_employeeManagememtService;
std::shared_ptr<LeaveManagementService> m_leaveManagementService;
std::shared_ptr<NotificationManagementService> m_notificationManagementService;
std::shared_ptr<PayslipManagementService> m_payslipManagementService;
std::shared_ptr<TalentAcquisitionManagementService> m_talentAcquisitionManagementService;
std::shared_ptr<TeamManagementService> m_teamManagementService;
std::shared_ptr<TicketManagementService> m_ticketManagementService;
public:
ZenvyController() :
m_authenticationManagementService(std::make_shared<AuthenticationManagementService>()),
m_attendanceManagementService(std::make_shared<AttendanceManagementService>()),
m_bookingManagementService(std::make_shared<BookingManagementService>()),
m_employeeManagememtService(std::make_shared<EmployeeManagememtService>()),
m_leaveManagementService(std::make_shared<LeaveManagementService>()),
m_notificationManagementService(std::make_shared<NotificationManagementService>()),
m_payslipManagementService(std::make_shared<PayslipManagementService>()),
m_talentAcquisitionManagementService(std::make_shared<TalentAcquisitionManagementService>()),
m_teamManagementService(std::make_shared<TeamManagementService>()),
m_ticketManagementService(std::make_shared<TicketManagementService>()) {};
//Authentication
AuthenticationContext login(const std::string& email, const std::string& password);
void logout();
void changePassword(const std::string&);
};
@@ -1 +1,33 @@
#include "DataStore.h"
DataStore& DataStore::getInstance()
{
static DataStore dataStore;
return dataStore;
}
logMap& DataStore::getLogs()
{
return m_logs;
}
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
{
return m_authenticatedEmployee;
}
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
{
m_authenticatedEmployee = authenticatedEmployee;
}
employeeMap& DataStore::getEmployees()
{
return m_employees;
}
std::shared_ptr<Employee>& DataStore::getAuthenticatedUser()
{
return m_authenticatedEmployee;
}
@@ -1,5 +1,43 @@
#pragma once
#include <memory>
#include <map>
#include "Employee.h"
#include "Log.h"
#include "Timestamp.h"
#include "Admin.h"
#include "HRManager.h"
#include "GeneralEmployee.h"
#include "ITExecutive.h"
#include "FinanceExecutive.h"
#include "TeamExecutive.h"
#include "TalentExecutive.h"
#include "Team.h"
#include "Room.h"
#include "Ticket.h"
#include "JobListing.h"
#include "Notification.h"
#include "Announcement.h"
#include "Faq.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>;
class DataStore
{
};
private:
std::shared_ptr<Employee> m_authenticatedEmployee;
employeeMap m_employees;
logMap m_logs;
DataStore() = default;
public:
static DataStore& getInstance();
DataStore(const DataStore&) = delete;
DataStore& operator=(const DataStore&) = delete;
DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees();
std::shared_ptr<Employee>& getAuthenticatedUser();
logMap& getLogs();
std::shared_ptr<Employee>& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
};
@@ -122,4 +122,9 @@ void Employee::addLeave(std::shared_ptr<Leave> leave)
{
m_leaves[leave->getLeaveId()] = leave;
}
}
}
Enums::EmployeeType Employee::getEmployeeType() const
{
return m_employeeType;
}
@@ -26,16 +26,18 @@ private:
payslipMap m_payslips;
attendanceMap m_attendances;
leaveMap m_leaves;
Enums::EmployeeType m_employeeType;
public:
Employee() : m_id(""), m_password(""), m_name(""), m_phone(""), m_email(""), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId("") {}
Employee() : m_id(""), m_password(""), m_name(""), m_phone(""), m_email(""), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(""), m_employeeType(Enums::EmployeeType::GENERAL) {}
Employee(const std::string& id,
const std::string& password,
const std::string& name,
const std::string& phone,
const std::string& email,
const std::string& teamId,
Enums::EmployeeType employeeType,
std::shared_ptr<Payroll> payroll)
: m_id(id), m_password(password), m_name(name), m_phone(phone), m_email(email), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(teamId), m_payroll(payroll) {}
: m_id(id), m_password(password), m_name(name), m_phone(phone), m_email(email), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(teamId), m_employeeType(employeeType), m_payroll(payroll) { }
const std::string& getEmployeeId() const;
const std::string& getEmployeePassword() const;
const std::string& getEmployeeName() const;
@@ -59,5 +61,6 @@ public:
void addPayslip(std::shared_ptr<Payslip> payslip);
void addAttendance(std::shared_ptr<Attendance> attendance);
void addLeave(std::shared_ptr<Leave> leave);
~Employee() = default;
Enums::EmployeeType getEmployeeType() const;
virtual ~Employee() = default;
};
@@ -0,0 +1 @@
#include "Faq.h"
+6
View File
@@ -0,0 +1,6 @@
#pragma once
class Faq
{
};
@@ -15,8 +15,7 @@ public:
const std::string& email,
const std::string& teamId,
std::shared_ptr<Payroll> payroll,
Enums::EmployeeDesignation designation)
: Employee(id, password, name, phone, email, teamId, payroll), m_designation(designation) {}
Enums::EmployeeDesignation designation) : Employee(id, password, name, phone, email, teamId,Enums::EmployeeType::GENERAL, payroll), m_designation(designation) {}
Enums::EmployeeDesignation getDesignation() const;
void setDesignation(Enums::EmployeeDesignation designation);
~GeneralEmployee() = default;
+2 -2
View File
@@ -9,8 +9,8 @@ private:
std::string m_message;
public:
Log() : m_timestamp(), m_message("") {}
Log(const util::Timestamp& timestamp, const std::string& message)
: m_timestamp(timestamp), m_message(message) {}
Log(const std::string& message)
: m_timestamp(), m_message(message) {}
const util::Timestamp& getTimestamp() const;
const std::string& getMessage() const;
void setTimestamp(const util::Timestamp& timestamp);
@@ -0,0 +1 @@
#include "ApplicationConfig.h"
@@ -0,0 +1,6 @@
#pragma once
namespace Config
{
constexpr const char* DEFAULT_PASSWORD = "password";
}
@@ -1 +1,70 @@
#include <stdexcept>
#include "AuthenticationManagementService.h"
#include "ApplicationConfig.h"
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> AuthenticationManagementService::login(const std::string& email, const std::string& password)
{
employeeMap& employees = m_dataStore.getEmployees();
Enums::LoginStatus loginStatus = Enums::LoginStatus::USER_NOT_FOUND;
Enums::EmployeeType employeeType = Enums::EmployeeType::INVALID;
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
for (const auto& employee : employees)
{
if (employee.second->getEmployeeEmail() == email)
{
if (employee.second->getEmployeePassword() == password)
{
if (password == Config::DEFAULT_PASSWORD)
{
loginStatus = Enums::LoginStatus::FIRST_LOGIN;
}
else
{
loginStatus = Enums::LoginStatus::SUCCESS;
}
employeeType = employee.second->getEmployeeType();
if (employeeType == Enums::EmployeeType::GENERAL)
{
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second);
if (generalEmployee)
{
employeeDesignation = generalEmployee->getDesignation();
}
else
{
throw std::runtime_error("Invalid Employee Type");
}
}
m_dataStore.setAuthenticatedEmployee(employee.second);
}
else
{
loginStatus = Enums::LoginStatus::INVALID_PASSWORD;
}
break;
}
}
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");
}
}
void AuthenticationManagementService::logout() {
if (m_dataStore.getAuthenticatedUser()) {
m_dataStore.getAuthenticatedUser() = nullptr;
}
else {
throw std::runtime_error("No user currently logged In...");
}
}
@@ -1,5 +1,19 @@
#pragma once
#include <string>
#include <map>
#include <utility>
#include <stdexcept>
#include "DataStore.h"
#include "Enums.h"
class AuthenticationManagementService
{
private:
DataStore& m_dataStore;
public:
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {};
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> login(const std::string& username, const std::string& password);
void logout();
void changePassword(const std::string&);
};
@@ -1 +1,12 @@
#include "LogService.h"
#include "Log.h"
#include "Factory.h"
#include "DataStore.h"
void LogService::log(const std::string& message)
{
DataStore& dataStore = DataStore::getInstance();
logMap& logs = dataStore.getLogs();
std::shared_ptr<Log> log = Factory::getObject<Log>(message);
logs.emplace(std::make_pair(log->getTimestamp(), log));
}
@@ -1,5 +1,8 @@
#pragma once
#include "Log.h"
class LogService
{
public:
static void log(const std::string&);
};
+21 -1
View File
@@ -66,7 +66,27 @@ namespace Enums {
{
JUNIOR,
SENIOR,
TEAM_LEAD
TEAM_LEAD,
INVALID
};
enum class EmployeeType
{
GENERAL,
IT,
FINANCE,
TAG,
HR,
TEAM,
ADMIN,
INVALID
};
enum class LoginStatus
{
SUCCESS,
FIRST_LOGIN,
USER_NOT_FOUND,
INVALID_PASSWORD
};
}
@@ -1,11 +1 @@
#include "inputHelper.h"
void util::readString(std::string& value)
{
getline(std::cin >> std::ws, value);
}
void util::pressEnter()
{
system("pause");
}
@@ -1,4 +1,5 @@
#pragma once
#include <iostream>
#include <limits>
#include <string>
@@ -6,18 +7,24 @@
namespace util
{
template <typename T>
void readValue(T& value)
{
std::cin >> value;
if (std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
throw std::runtime_error("Invalid Console Input");
}
}
template <typename T>
inline void read(T& value)
{
if (!(std::cin >> value))
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
throw std::runtime_error("Invalid console input");
}
}
void readString(std::string&);
void pressEnter();
inline void read(std::string& value)
{
std::getline(std::cin >> std::ws, value);
}
inline void pressEnter()
{
system("pause");
}
}
@@ -1,4 +1,7 @@
#include <string>
#include <cctype>
#include "Validator.h"
#include "ApplicationConfig.h"
bool util::isPhoneNumberValid(const std::string& phoneNumber) {
if (phoneNumber.size() != 10)
@@ -26,3 +29,43 @@ bool util::isEmailValid(const std::string& email) {
}
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 isEmailValid(const std::string&);
bool isPasswordValid(const std::string&);
}
@@ -0,0 +1,52 @@
#include <iostream>
#include "AdminMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void AdminMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - HR Management System\n1. Create HRManager\n2. Create Employee\n3. View Employee\n4. Deactivate Employee\n5. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool AdminMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.createHRManager();
break;
case 2:
m_zenvyController.createEmployee();
break;
case 3:
m_zenvyController.viewEmployee();
break;
case 4:
m_zenvyController.deactivateEmployee();
break;*/
case 5:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class AdminMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,79 @@
#include <iostream>
#include "EmployeeMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void EmployeeMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticke\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n14. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool EmployeeMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
case 4 :
m_zenvyController.raiseTicket();
break;
case 5 :
m_zenvyController.viewTicket();
break;
case 6:
m_zenvyController.viewTicketHistory();
break;
case 7:
m_zenvyController.viewEmployees();
break;
case 8:
m_zenvyController.searchEmployee();
break;
case 9:
m_zenvyController.viewTeamMembers();
break;
case 10:
m_zenvyController.bookMeetingRoom();
break;
case 11:
m_zenvyController.viewBookingHistory();
break;
case 12:
m_zenvyController.viewNotifications();
break;
case 13:
m_zenvyController.viewAnnouncements();
break;*/
case 14:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class EmployeeMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,70 @@
#include <iostream>
#include "FinanceExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void FinanceExecutiveMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslip\n10. Update Payroll\n11. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool FinanceExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
case 4:
m_zenvyController.viewEmployees();
break;
case 5:
m_zenvyController.searchEmployee();
break;
case 6:
m_zenvyController.viewNotifications();
break;
case 7:
m_zenvyController.viewAnnouncements();
break;
case 8:
m_zenvyController.resolveTicket();
break;
case 9:
m_zenvyController.generatePayslip();
break;
case 10:
m_zenvyController.updatePayroll();
break;*/
case 11:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class FinanceExecutiveMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,73 @@
#include <iostream>
#include "HRManagerMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void HRManagerMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Register CandidateAsEmployee\n12. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool HRManagerMenu::handleOperation(int choice)
{
switch (choice)
{
//case 1:
// m_zenvyController.applyLeave();
// break;
//case 2:
// m_zenvyController.viewPayslip();
// break;
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
//case 6:
// m_zenvyController.viewNotifications();
// break;
//case 7:
// m_zenvyController.viewAnnouncements();
// break;
//case 8:
// m_zenvyController.createEmployee();
// break;
//case 9:
// m_zenvyController.regularizeAttenance();
// break;
//case 10:
// m_zenvyController.updateLeaveRequest();
// break;
//case 11:
// m_zenvyController.registercandidateAsEmployee();
// break;
case 12:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class HRManagerMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,64 @@
#include <iostream>
#include "ITExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void ITExecutiveMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool ITExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
case 4:
m_zenvyController.viewEmployees();
break;
case 5:
m_zenvyController.searchEmployee();
break;
case 6:
m_zenvyController.viewNotifications();
break;
case 7:
m_zenvyController.viewAnnouncements();
break;
case 8:
m_zenvyController.resolveTicket();
break;*/
case 9:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class ITExecutiveMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,76 @@
#include <iostream>
#include "TalentExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void TalentExecutiveMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create New Job\n9. View Job Opening\n10. Add Candidate\n11. UpdateCandidate Status\n12. View Shortlisted Candidate\n13. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool TalentExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
//case 1:
// m_zenvyController.applyLeave();
// break;
//case 2:
// m_zenvyController.viewPayslip();
// break;
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
//case 6:
// m_zenvyController.viewNotifications();
// break;
//case 7:
// m_zenvyController.viewAnnouncements();
// break;
//case 8:
// m_zenvyController.createNewJob();
// break;
//case 9:
// m_zenvyController.viewJobOpenings();
// break;
//case 10:
// m_zenvyController.addCandidate();
// break;
//case 11:
// m_zenvyController.updateCandidateStatus();
// break;
//case 12:
// m_zenvyController.viewShortlistedCandidates();
// break;
case 13:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class TalentExecutiveMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,79 @@
#include <iostream>
#include "TeamExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void TeamExecutiveMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Team\n9. Update Team\n10. Remove Team\n11. Assign Employee\n12. Unassign Employee\n13. View Teams\n14. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool TeamExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
//case 1:
// m_zenvyController.applyLeave();
// break;
//case 2:
// m_zenvyController.viewPayslip();
// break;
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
//case 6:
// m_zenvyController.viewNotifications();
// break;
//case 7:
// m_zenvyController.viewAnnouncements();
// break;
//case 8:
// m_zenvyController.createTeam();
// break;
//case 9:
// m_zenvyController.updateTeam();
// break;
//case 10:
// m_zenvyController.removeTeam();
// break;
//case 11:
// m_zenvyController.assignEmployee();
// break;
//case 12:
// m_zenvyController.unassignEmployee();
// break;
//case 13:
// m_zenvyController.viewTeams();
// break;
case 14:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class TeamExecutiveMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
TeamExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,85 @@
#include <iostream>
#include "TeamLeadMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
void TeamLeadMenu::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticke\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n4. Regularize Attendance\n15. Update Leave Request\n16. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool TeamLeadMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;
case 3:
m_zenvyController.viewPayslipHistory();
break;
case 4:
m_zenvyController.raiseTicket();
break;
case 5:
m_zenvyController.viewTicket();
break;
case 6:
m_zenvyController.viewTicketHistory();
break;
case 7:
m_zenvyController.viewEmployees();
break;
case 8:
m_zenvyController.searchEmployee();
break;
case 9:
m_zenvyController.viewTeamMembers();
break;
case 10:
m_zenvyController.bookMeetingRoom();
break;
case 11:
m_zenvyController.viewBookingHistory();
break;
case 12:
m_zenvyController.viewNotifications();
break;
case 13:
m_zenvyController.viewAnnouncements();
break;
case 14:
m_zenvyController.regularizeAttendance();
break;
case 15:
m_zenvyController.updateLeaveRequest();
break;*/
case 16:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
}
return true;
}
@@ -0,0 +1,14 @@
#pragma once
#include<memory>
#include"ZenvyController.h"
class TeamLeadMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
public:
TeamLeadMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
};
@@ -0,0 +1,162 @@
#include <iostream>
#include <utility>
#include <memory>
#include <stdexcept>
#include "UserInterface.h"
#include "AdminMenu.h"
#include "EmployeeMenu.h"
#include "FinanceExecutiveMenu.h"
#include "HRManagerMenu.h"
#include "ITExecutiveMenu.h"
#include "TalentExecutiveMenu.h"
#include "TeamExecutiveMenu.h"
#include "TeamLeadMenu.h"
#include "ZenvyController.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "Validator.h"
void UserInterface::run()
{
bool isMenuActive = true;
while (isMenuActive)
{
try
{
int choice;
util::clear();
std::cout << "Zenvy - HR Management System\n1. Login\n2. Exit\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
isMenuActive = false;
}
}
catch (const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
util::pressEnter();
}
}
}
bool UserInterface::handleOperation(int choice)
{
switch (choice)
{
case 1:
login();
break;
case 2:
std::cout << "Exiting..." << std::endl;
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
util::pressEnter();
}
return true;
}
void UserInterface::login()
{
std::string email, password;
util::clear();
std::cout << "Enter email: ";
util::read(email);
std::cout << "Enter password: ";
util::read(password);
AuthenticationContext authenticationContext = m_controller->login(email, password);
Enums::LoginStatus loginStatus = std::get<0>(authenticationContext);
Enums::EmployeeType employeeType = std::get<1>(authenticationContext);
Enums::EmployeeDesignation employeeDesignation = std::get<2>(authenticationContext);
if (loginStatus == Enums::LoginStatus::USER_NOT_FOUND)
{
std::cout << "Error: User Not Found! Try Again\n";
util::pressEnter();
return;
}
if (loginStatus == Enums::LoginStatus::INVALID_PASSWORD)
{
std::cout << "Error: Invalid Password! Try Again\n";
util::pressEnter();
return;
}
if (loginStatus == Enums::LoginStatus::FIRST_LOGIN)
{
util::clear();
std::cout << "Warning: You're using the default password!\n"
<< "Please change it.\n";
std::cout << "Enter new password: \n";
util::read(password);
if (util::isPasswordValid(password))
{
m_controller->changePassword(password);
}
else
{
std::cout << "\nInvalid Password";
util::pressEnter();
return;
}
}
util::clear();
// Route to appropriate menu
switch (employeeType)
{
case Enums::EmployeeType::ADMIN:
{
AdminMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::HR:
{
HRManagerMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::FINANCE:
{
FinanceExecutiveMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::IT:
{
ITExecutiveMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::TEAM:
{
TeamExecutiveMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::TAG:
{
TalentExecutiveMenu menu;
menu.run();
break;
}
case Enums::EmployeeType::GENERAL:
{
if (employeeDesignation == Enums::EmployeeDesignation::TEAM_LEAD)
{
TeamLeadMenu menu;
menu.run();
}
else
{
EmployeeMenu menu;
menu.run();
}
break;
}
default:
throw std::runtime_error("Error: Unsupported employee type!\n");
util::pressEnter();
break;
}
m_controller->logout();
}
@@ -0,0 +1,40 @@
#pragma once
#include <memory>
#include <utility>
#include "AdminMenu.h"
#include "EmployeeMenu.h"
#include "FinanceExecutiveMenu.h"
#include "HRManagerMenu.h"
#include "ITExecutiveMenu.h"
#include "TalentExecutiveMenu.h"
#include "TeamExecutiveMenu.h"
#include "TeamLeadMenu.h"
#include "ZenvyController.h"
class UserInterface
{
private:
std::shared_ptr<ZenvyController> m_controller;
std::shared_ptr<EmployeeMenu> m_employeeMenu;
std::shared_ptr<AdminMenu> m_adminMenu;
std::shared_ptr<FinanceExecutiveMenu> m_financeExecutiveMenu;
std::shared_ptr<HRManagerMenu> m_hrManagerMenu;
std::shared_ptr<ITExecutiveMenu> m_itExecutiveMenu;
std::shared_ptr<TalentExecutiveMenu> m_talentExecutiveMenu;
std::shared_ptr<TeamExecutiveMenu> m_teamExecutiveMenu;
std::shared_ptr<TeamLeadMenu> m_teamLeadMenu;
public:
UserInterface() : m_controller(std::make_shared<ZenvyController>()),
m_employeeMenu(std::make_shared<EmployeeMenu>()),
m_adminMenu(std::make_shared<AdminMenu>()),
m_financeExecutiveMenu(std::make_shared<FinanceExecutiveMenu>()),
m_hrManagerMenu(std::make_shared<HRManagerMenu>()),
m_itExecutiveMenu(std::make_shared<ITExecutiveMenu>()),
m_talentExecutiveMenu(std::make_shared<TalentExecutiveMenu>()),
m_teamExecutiveMenu(std::make_shared<TeamExecutiveMenu>()),
m_teamLeadMenu(std::make_shared<TeamLeadMenu>()) {};
void run();
bool handleOperation(int choice);
void login();
};