AuthManager

- Implemented `removeUser(string username)`
- Implemented `addUser(String)`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-11-19 16:07:27 +02:00
parent 8781354616
commit e2d378f5a5
1 changed files with 26 additions and 1 deletions

View File

@ -170,15 +170,40 @@ public class AuthManager
return foundUser;
}
private void addUser(string username)
{
// Lock
this.usersLock.lock();
// Create the user and insert it
User* newUser = new User(username);
this.users[username] = newUser;
// Unlock
this.usersLock.unlock();
}
private void removeUser(string username)
{
// Lock
this.usersLock.lock();
// Remove the user
this.users.remove(username);
// Unlock
this.usersLock.unlock();
}
public bool authenticate(string username, string password)
{
logger.dbg("Authentication request for user '"~username~"' with password '"~password~"'");
bool status;
User potentialUser = User("");
status = this.provider.authenticate(username, password);
if(status)
{
addUser(username);
logger.info("Authenticated user '"~username~"'");
}
else