Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| def0f4022b | |||
| fcc612f081 | |||
| e7332af1e7 | |||
| fb35ee6098 |
@@ -1,4 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* File: Trenser.Zenvy.cpp
|
||||||
|
* Description: Zenvy Main
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
UserInterface userInterFace;
|
UserInterface userInterFace;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "ZenvyController.h"
|
#include "ZenvyController.h"
|
||||||
|
|
||||||
//Authentication
|
//Authentication
|
||||||
AuthenticationContext ZenvyController::login(const std::string& email, const std::string& password)
|
AuthenticationDTO ZenvyController::login(const std::string& email, const std::string& password)
|
||||||
{
|
{
|
||||||
return m_authenticationManagementService->login(email, password);
|
return m_authenticationManagementService->login(email, password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#include "TicketManagementService.h"
|
#include "TicketManagementService.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
|
|
||||||
using AuthenticationContext = std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation>;
|
|
||||||
|
|
||||||
class ZenvyController
|
class ZenvyController
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -42,7 +40,7 @@ public:
|
|||||||
m_ticketManagementService(std::make_shared<TicketManagementService>()) {};
|
m_ticketManagementService(std::make_shared<TicketManagementService>()) {};
|
||||||
|
|
||||||
//Authentication
|
//Authentication
|
||||||
AuthenticationContext login(const std::string& email, const std::string& password);
|
AuthenticationDTO login(const std::string& email, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
void changePassword(const std::string&);
|
void changePassword(const std::string&);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: ApplicationConfig.cpp
|
||||||
|
* Description: Global Application Config
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 06-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "ApplicationConfig.h"
|
#include "ApplicationConfig.h"
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* File: ApplicationConfig.h
|
||||||
|
* Description: Global Application Config
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 06-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
constexpr const char* DEFAULT_PASSWORD = "password";
|
namespace Authentication
|
||||||
|
{
|
||||||
|
constexpr const char* DEFAULT_PASSWORD = "password";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: AttendanceManagementService.cpp
|
||||||
|
* Description: Handles Attendance related operations
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "AttendanceManagementService.h"
|
#include "AttendanceManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: AttendanceManagementService.h
|
||||||
|
* Description: Handles Attendance related operations
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class AttendanceManagementService
|
class AttendanceManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,65 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* File: AuthenticationManagementService.cpp
|
||||||
|
* Description: Handles authentication related operations
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "ApplicationConfig.h"
|
#include "ApplicationConfig.h"
|
||||||
|
|
||||||
std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation> AuthenticationManagementService::login(const std::string& email, const std::string& password)
|
/*
|
||||||
|
* Function: login
|
||||||
|
* Description: Authenticates a user using email and password, determines login status,
|
||||||
|
* employee type, and designation, and sets the authenticated employee
|
||||||
|
* in the data store.
|
||||||
|
* Parameters:
|
||||||
|
* email - employee email address
|
||||||
|
* password - employee password
|
||||||
|
* Returns:
|
||||||
|
* AuthenticationDTO containing login status, employee type, and employee designation
|
||||||
|
*/
|
||||||
|
AuthenticationDTO AuthenticationManagementService::login(const std::string& email, const std::string& password)
|
||||||
{
|
{
|
||||||
employeeMap& employees = m_dataStore.getEmployees();
|
employeeMap& employees = m_dataStore.getEmployees();
|
||||||
Enums::LoginStatus loginStatus = Enums::LoginStatus::USER_NOT_FOUND;
|
Enums::LoginStatus loginStatus = Enums::LoginStatus::USER_NOT_FOUND;
|
||||||
Enums::EmployeeType employeeType = Enums::EmployeeType::INVALID;
|
Enums::EmployeeType employeeType = Enums::EmployeeType::INVALID;
|
||||||
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
||||||
for (const auto& employee : employees)
|
for (const auto& employee : employees)
|
||||||
{
|
{
|
||||||
if (employee.second->getEmployeeEmail() == email)
|
if (employee.second->getEmployeeEmail() == email)
|
||||||
{
|
{
|
||||||
if (employee.second->getEmployeePassword() == password)
|
if (employee.second->getEmployeePassword() == password)
|
||||||
{
|
{
|
||||||
if (password == Config::DEFAULT_PASSWORD)
|
if (password == Config::Authentication::DEFAULT_PASSWORD)
|
||||||
{
|
{
|
||||||
loginStatus = Enums::LoginStatus::FIRST_LOGIN;
|
loginStatus = Enums::LoginStatus::FIRST_LOGIN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginStatus = Enums::LoginStatus::SUCCESS;
|
loginStatus = Enums::LoginStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
employeeType = employee.second->getEmployeeType();
|
employeeType = employee.second->getEmployeeType();
|
||||||
if (employeeType == Enums::EmployeeType::GENERAL)
|
if (employeeType == Enums::EmployeeType::GENERAL)
|
||||||
{
|
{
|
||||||
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second);
|
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second);
|
||||||
if (generalEmployee)
|
if (generalEmployee)
|
||||||
{
|
{
|
||||||
employeeDesignation = generalEmployee->getDesignation();
|
employeeDesignation = generalEmployee->getDesignation();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Invalid Employee Type");
|
throw std::runtime_error("Invalid Employee Type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_dataStore.setAuthenticatedEmployee(employee.second);
|
m_dataStore.setAuthenticatedEmployee(employee.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginStatus = Enums::LoginStatus::INVALID_PASSWORD;
|
loginStatus = Enums::LoginStatus::INVALID_PASSWORD;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::make_tuple(loginStatus, employeeType, employeeDesignation);
|
return std::make_tuple(loginStatus, employeeType, employeeDesignation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function: changePassword
|
||||||
|
* Description: Updates the password of the currently authenticated user.
|
||||||
|
* Parameters:
|
||||||
|
* password - new password to be set
|
||||||
|
* Returns:
|
||||||
|
* None
|
||||||
|
* Throws:
|
||||||
|
* runtime_error if no authenticated user is found
|
||||||
|
*/
|
||||||
void AuthenticationManagementService::changePassword(const std::string& password)
|
void AuthenticationManagementService::changePassword(const std::string& password)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedUser();
|
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedUser();
|
||||||
if (authenticatedUser)
|
if (authenticatedUser)
|
||||||
{
|
{
|
||||||
authenticatedUser->setEmployeePassword(password);
|
authenticatedUser->setEmployeePassword(password);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error("User not found");
|
throw std::runtime_error("User not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function: logout
|
||||||
|
* Description: Logs out the currently authenticated user by clearing authentication data.
|
||||||
|
* Parameters:
|
||||||
|
* None
|
||||||
|
* Returns:
|
||||||
|
* None
|
||||||
|
* Throws:
|
||||||
|
* runtime_error if no user is currently logged in
|
||||||
|
*/
|
||||||
void AuthenticationManagementService::logout() {
|
void AuthenticationManagementService::logout() {
|
||||||
if (m_dataStore.getAuthenticatedUser()) {
|
if (m_dataStore.getAuthenticatedUser()) {
|
||||||
m_dataStore.getAuthenticatedUser() = nullptr;
|
m_dataStore.getAuthenticatedUser() = nullptr;
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* File: AuthenticationManagementService.h
|
||||||
|
* Description: Handles authentication related operations
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
|
|
||||||
|
using AuthenticationDTO = std::tuple<Enums::LoginStatus, Enums::EmployeeType, Enums::EmployeeDesignation>;
|
||||||
|
|
||||||
class AuthenticationManagementService
|
class AuthenticationManagementService
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
DataStore& m_dataStore;
|
DataStore& m_dataStore;
|
||||||
public:
|
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);
|
AuthenticationDTO login(const std::string& username, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
void changePassword(const std::string&);
|
void changePassword(const std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: BookingManagementService.cpp
|
||||||
|
* Description: Handle operations related to booking meetings
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "BookingManagementService.h"
|
#include "BookingManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: BookingManagementService.h
|
||||||
|
* Description: Handle operations related to booking meetings
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class BookingManagementService
|
class BookingManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: EmployeeManagementService.cpp
|
||||||
|
* Description: Handle operations related to employees
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "EmployeeManagememtService.h"
|
#include "EmployeeManagememtService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: EmployeeManagementService.h
|
||||||
|
* Description: Handle operations related to employees
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class EmployeeManagememtService
|
class EmployeeManagememtService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: LeaveManagementService.cpp
|
||||||
|
* Description: Handle operations related to leaves
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "LeaveManagementService.h"
|
#include "LeaveManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: LeaveManagementService.h
|
||||||
|
* Description: Handle operations related to leaves
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class LeaveManagementService
|
class LeaveManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: Log.cpp
|
||||||
|
* Description: Handle operations related to logging
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 01-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "LogService.h"
|
#include "LogService.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Factory.h"
|
#include "Factory.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: Log.h
|
||||||
|
* Description: Handle operations related to logging
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 01-Apr-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: NotificationManagementService.cpp
|
||||||
|
* Description: Handle operations related to notifications
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "NotificationManagementService.h"
|
#include "NotificationManagementService.h"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* File: NotificationManagementService.h
|
||||||
|
* Description: Handle operations related to notifications
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class NotificationManagementService
|
class NotificationManagementService
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: PayslipManagementService.cpp
|
||||||
|
* Description: Handle operations related to employee payslips
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "PayslipManagementService.h"
|
#include "PayslipManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: PayslipManagementService.h
|
||||||
|
* Description: Handle operations related to employee payslips
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class PayslipManagementService
|
class PayslipManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: TalentAcquisitionManagementService.cpp
|
||||||
|
* Description: Handle operations related to Talent Acquisition
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "TalentAcquisitionManagementService.h"
|
#include "TalentAcquisitionManagementService.h"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* File: TalentAcquisitionManagementService.h
|
||||||
|
* Description: Handle operations related to Talent Acquisition
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class TalentAcquisitionManagementService
|
class TalentAcquisitionManagementService
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: TeamManagementService.cpp
|
||||||
|
* Description: Handle operations related to Team Management
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "TeamManagementService.h"
|
#include "TeamManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: TeamManagementService.h
|
||||||
|
* Description: Handle operations related to Team Management
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class TeamManagementService
|
class TeamManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* File: TicketManagementService.h
|
||||||
|
* Description: Handle operations related to Ticket Management
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "TicketManagementService.h"
|
#include "TicketManagementService.h"
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* File: TicketManagementService.h
|
||||||
|
* Description: Handle operations related to Ticket Management
|
||||||
|
* Author: Trenser
|
||||||
|
* Created: 30-Mar-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
class TicketManagementService
|
class TicketManagementService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ bool util::isEmailValid(const std::string& email) {
|
|||||||
|
|
||||||
bool util::isPasswordValid(const std::string& password)
|
bool util::isPasswordValid(const std::string& password)
|
||||||
{
|
{
|
||||||
if (password == Config::DEFAULT_PASSWORD)
|
if (password == Config::Authentication::DEFAULT_PASSWORD)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void UserInterface::login()
|
|||||||
util::read(email);
|
util::read(email);
|
||||||
std::cout << "Enter password: ";
|
std::cout << "Enter password: ";
|
||||||
util::read(password);
|
util::read(password);
|
||||||
AuthenticationContext authenticationContext = m_controller->login(email, password);
|
AuthenticationDTO authenticationContext = m_controller->login(email, password);
|
||||||
Enums::LoginStatus loginStatus = std::get<0>(authenticationContext);
|
Enums::LoginStatus loginStatus = std::get<0>(authenticationContext);
|
||||||
Enums::EmployeeType employeeType = std::get<1>(authenticationContext);
|
Enums::EmployeeType employeeType = std::get<1>(authenticationContext);
|
||||||
Enums::EmployeeDesignation employeeDesignation = std::get<2>(authenticationContext);
|
Enums::EmployeeDesignation employeeDesignation = std::get<2>(authenticationContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user