Exemple #1
0
        //SSO登陆产生令牌
        public string SSO_Token(UserSSOInfo userSSOInfo)
        {
            string token = $"{Guid.NewGuid().ToString()}";

            //string value = ServiceStack.Text.JsonSerializer.SerializeToString(userSSOInfo);
            redis.Set <UserSSOInfo>(token, userSSOInfo, DateTime.Now.AddHours(session_erpire));
            _token = token;
            return(token);
        }
Exemple #2
0
        //查询token是否有效(在应用程序中)
        public UserSSOInfo SSO_Token_IsExist()
        {
            UserSSOInfo info = new UserSSOInfo();

            info = redis.Get <UserSSOInfo>(_token);
            //if (string.IsNullOrEmpty(value))
            //    return null;
            ////重置过期时间
            //return ServiceStack.Text.JsonSerializer.DeserializeFromString<UserSSOInfo>(value);
            return(info);
        }
Exemple #3
0
        //public SSOManager(UserSSOInfo userSSOInfo)
        //{
        //    _userSSOInfo = userSSOInfo;
        //}

        public SSOManager()
        {
            if (HttpContext.Current != null && HttpContext.Current.Session["token"] != null)
            {
                _token    = HttpContext.Current.Session["token"].ToString();
                _userinfo = SSO_Token_IsExist();
            }
            else
            {
                _token = "";
            }
        }