disable working
This commit is contained in:
@@ -622,3 +622,8 @@ void Controller::shutdown()
|
||||
auto& dataStore = DataStore::getInstance();
|
||||
dataStore.shutdown();
|
||||
}
|
||||
|
||||
void Controller::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent)
|
||||
{
|
||||
m_authenticationManagementService.registerEvents(accountDisabledEvent, notificationAvailableEvent);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ Date:19-May-2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include "AuthenticationManagementService.h"
|
||||
#include "Enums.h"
|
||||
@@ -72,4 +73,5 @@ public:
|
||||
void configureNotifications(bool paymentNotifications, bool serviceNotifications);
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
void registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent);
|
||||
};
|
||||
+14
-7
@@ -16,6 +16,8 @@ Date:19-May-2026
|
||||
|
||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||
EventManager AuthenticationManagementService::m_eventManager;
|
||||
HANDLE AuthenticationManagementService::m_accountDisabledEvent = NULL;
|
||||
HANDLE AuthenticationManagementService::m_notificationsAvailableEvent = NULL;
|
||||
|
||||
/*
|
||||
Function: login
|
||||
@@ -43,20 +45,17 @@ bool AuthenticationManagementService::login(const std::string& username, const s
|
||||
user->getId(),
|
||||
[]()
|
||||
{
|
||||
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_AccountDisabled");
|
||||
if (eventHandle)
|
||||
if (m_accountDisabledEvent)
|
||||
{
|
||||
SetEvent(eventHandle);
|
||||
CloseHandle(eventHandle);
|
||||
SetEvent(m_accountDisabledEvent);
|
||||
}
|
||||
},
|
||||
[]()
|
||||
{
|
||||
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_NotificationAvailable");
|
||||
if (eventHandle)
|
||||
if (m_notificationsAvailableEvent)
|
||||
{
|
||||
SetEvent(eventHandle);
|
||||
CloseHandle(eventHandle);
|
||||
SetEvent(m_notificationsAvailableEvent);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@@ -89,6 +88,8 @@ void AuthenticationManagementService::logout()
|
||||
{
|
||||
m_eventManager.shutdown();
|
||||
m_authenticatedUser = nullptr;
|
||||
m_accountDisabledEvent = NULL;
|
||||
m_notificationsAvailableEvent = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,3 +116,9 @@ void AuthenticationManagementService::changePassword(const std::string& newPassw
|
||||
trackedUsersMap.getValueAt(index).state = RecordState::MODIFIED;
|
||||
m_dataStore.saveUsers();
|
||||
}
|
||||
|
||||
void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notifictionAvailableEvent)
|
||||
{
|
||||
m_accountDisabledEvent = accountDisabledEvent;
|
||||
m_notificationsAvailableEvent = notifictionAvailableEvent;
|
||||
}
|
||||
|
||||
+4
@@ -9,6 +9,7 @@ Date:19-May-2026
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include "EventManager.h"
|
||||
#include "DataStore.h"
|
||||
|
||||
@@ -19,6 +20,8 @@ class AuthenticationManagementService
|
||||
private:
|
||||
static User* m_authenticatedUser;
|
||||
static EventManager m_eventManager;
|
||||
static HANDLE m_accountDisabledEvent;
|
||||
static HANDLE m_notificationsAvailableEvent;
|
||||
DataStore& m_dataStore;
|
||||
public:
|
||||
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {}
|
||||
@@ -26,4 +29,5 @@ public:
|
||||
void logout();
|
||||
void changePassword(const std::string& newPassword);
|
||||
User* getAuthenticatedUser();
|
||||
void registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent);
|
||||
};
|
||||
|
||||
@@ -85,6 +85,11 @@ Return type: bool - true if menu continues, false if logout
|
||||
*/
|
||||
bool AdminMenu::handleOperation(int choice)
|
||||
{
|
||||
if (!m_isMenuActive)
|
||||
{
|
||||
logout();
|
||||
return false;
|
||||
}
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
|
||||
@@ -14,7 +14,6 @@ Date:19-May-2026
|
||||
class AdminMenu : Menu
|
||||
{
|
||||
private:
|
||||
Controller m_controller;
|
||||
bool handleOperation(int choice);
|
||||
public:
|
||||
void showMenu();
|
||||
|
||||
@@ -80,6 +80,11 @@ Return type: bool - true if menu continues, false if logout
|
||||
*/
|
||||
bool CustomerMenu::handleOperation(int choice)
|
||||
{
|
||||
if (!m_isMenuActive)
|
||||
{
|
||||
logout();
|
||||
return false;
|
||||
}
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
|
||||
@@ -15,7 +15,6 @@ Date:19-May-2026
|
||||
class CustomerMenu : Menu
|
||||
{
|
||||
private:
|
||||
Controller m_controller;
|
||||
bool handleOperation(int choice);
|
||||
public:
|
||||
void showMenu();
|
||||
|
||||
@@ -21,9 +21,10 @@ void Menu::startEventListener()
|
||||
}
|
||||
m_isMenuActive.store(true);
|
||||
m_hasNewNotifications.store(false);
|
||||
m_accountDisabledEvent = CreateEventA(NULL, FALSE, FALSE, "VehicleServiceSystem_AccountDisabled");
|
||||
m_notificationAvailableEvent = CreateEventA(NULL, FALSE, FALSE, "VehicleServiceSystem_NotificationAvailable");
|
||||
m_accountDisabledEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
m_notificationAvailableEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
m_shutdownEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
m_controller.registerEvents(m_accountDisabledEvent, m_notificationAvailableEvent);
|
||||
m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@ Date:16-Jun-2026
|
||||
#include <windows.h>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include "Controller.h"
|
||||
|
||||
class Menu
|
||||
{
|
||||
protected:
|
||||
Controller m_controller;
|
||||
std::atomic<bool> m_isMenuActive;
|
||||
std::atomic<bool> m_hasNewNotifications;
|
||||
HANDLE m_accountDisabledEvent;
|
||||
|
||||
@@ -70,6 +70,11 @@ Return type: bool - true if menu continues, false if logout
|
||||
*/
|
||||
bool TechnicianMenu::handleOperation(int choice)
|
||||
{
|
||||
if (!m_isMenuActive)
|
||||
{
|
||||
logout();
|
||||
return false;
|
||||
}
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
|
||||
@@ -14,7 +14,6 @@ Date:19-May-2026
|
||||
class TechnicianMenu : Menu
|
||||
{
|
||||
private:
|
||||
Controller m_controller;
|
||||
bool handleOperation(int choice);
|
||||
public:
|
||||
void showMenu();
|
||||
|
||||
Reference in New Issue
Block a user