Utopia-Canteen-System/Services/AppSession.cs

30 lines
862 B
C#

namespace UtopiaCanteenSystem.Services;
/// <summary>
/// Holds the current admin session state for the app.
/// </summary>
public class AppSession
{
public bool IsAdminAuthenticated { get; private set; }
public string AdminUsername { get; private set; } = string.Empty;
public string AdminEmployeeId { get; private set; } = string.Empty;
public DateTime? LoginTimeUtc { get; private set; }
public void SetAdminAuthenticated(string username, string employeeId)
{
IsAdminAuthenticated = true;
AdminUsername = username ?? string.Empty;
AdminEmployeeId = employeeId ?? string.Empty;
LoginTimeUtc = DateTime.UtcNow;
}
public void Logout()
{
IsAdminAuthenticated = false;
AdminUsername = string.Empty;
AdminEmployeeId = string.Empty;
LoginTimeUtc = null;
}
}