示例#1
0
        public static bool ValidateSession(string token, long nonce)
        {
            lock (o)
            {
                if (string.IsNullOrEmpty(token) || nonce == 0)
                {
                    return(false);
                }

                var controller = new ControllerContainer.SessionController();
                return(controller.Select("where token=@0 and nonce=@1", token, nonce).Any());
            }
        }
示例#2
0
        public static void TouchSession(string token, long nonce)
        {
            lock (o)
            {
                if (string.IsNullOrEmpty(token) || nonce == 0 || HttpContext.Current.Request.IsLocal)
                {
                    return;
                }

                var controller = new ControllerContainer.SessionController();

                var session = controller.Select("where token=@0", token).FirstOrDefault();

                if (session == null)
                {
                    throw new InvalidTokenException($"Invalid token [{token}]. Please re-authenticate.");
                }

                session.Nonce    = nonce;
                session.LastSeen = BlueConstants.BlueCurrentDate;

                controller.Save(session);
            }
        }