public static bool TryGetSession(string token, out SessionEntry entry) { bool success = AuthManager.m_sessions.TryGetValue(token, out entry); if (success) { entry.UpdateTime = DateTime.UtcNow; } return(success); }
public static bool OpenSession(string user, string password, out string token) { if (AuthManager.LoadUser(user, password, out UserEntry userEntry)) { if (userEntry.CurrentSession != null) { AuthManager.CloseSession(userEntry.CurrentSession.Token); } SessionEntry session = new SessionEntry(userEntry, token = AuthManager.GenerateToken()); bool success = AuthManager.m_sessions.TryAdd(session.Token, session); if (success) { userEntry.CurrentSession = session; } Logging.Print(string.Format("AuthManager.openSession: user: {0} password: {1} token: {2}", user, password, session.Token)); return(success); } token = null; return(false); }