public static void Logout(string sessionID) { var sesh = UserSessions.Where(X => X.sessionID == sessionID).FirstOrDefault(); UserSessions.Remove(sesh); //isLoggedIn = false; //LoginToken = null; }
public void RemoveUserSession(User user) { UserSession us = UserSessions.Where(u => u.Session == this && u.User == user).FirstOrDefault(); if (us != null) { UserSessions.Remove(us); } else { throw new Exception($"User not found for session: {this}"); } }
public static string retrieveToken(string sessionID) { var currentSesh = UserSessions.Where(x => x.sessionID == sessionID).FirstOrDefault(); if (currentSesh != null && !(currentSesh.expiryTimestamp < DateTime.Now)) { return(currentSesh.authToken); } else { UserSessions.Remove(currentSesh); return("expired"); } }