示例#1
0
        public static void Logout(string sessionID)
        {
            var sesh = UserSessions.Where(X => X.sessionID == sessionID).FirstOrDefault();

            UserSessions.Remove(sesh);
            //isLoggedIn = false;
            //LoginToken = null;
        }
示例#2
0
        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}");
            }
        }
示例#3
0
        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");
            }
        }