/// <summary> /// 删除登录信息 /// </summary> public virtual void EmptyCurrent() { FormsAuth.SingOut(); if (LoginProvider == "Cookie") { string val = WebHelper.GetCookie(LoginUserKey); if (!string.IsNullOrEmpty(val)) { string userId = DESEncrypt.Decrypt(val); WebHelper.RemoveCookie(LoginUserKey.Trim()); //CacheFactory.Cache().RemoveCache(LoginUserKey); //CacheFactory.Cache().RemoveCache(userId + "_" + LoginUserKey); //CacheFactory.Cache().RemoveCache("UID_" + userId + "_" + LoginUserKey); } } else { WebHelper.RemoveSession(LoginUserKey); } }
/// <summary> /// 是否已登录 /// </summary> /// <returns></returns> public virtual int IsOnLine() { Operator user = new Operator(); string key = FormsAuth.GetUserKey(); if (string.IsNullOrEmpty(key)) { return(-1); } key = "UID_" + key + "_" + LoginUserKey; user = CacheFactory.Cache().GetCache <Operator>(key); if (user == null) { return(-1); } //if (LoginProvider == "Cookie") //{ // //user = DESEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject<Operator>(); // //AuthorizeDataModel dataAuthorize = CacheFactory.Cache().GetCache<AuthorizeDataModel>(user.UserId + "_" + LoginUserKey); //} //else //{ // user = DESEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject<Operator>(); //} object token = CacheFactory.Cache().GetCache <string>(user.UserId + "_" + LoginUserKey); if (token == null) { return(-1);//过期 } if (user.Token == token.ToString()) { return(1);//正常 } else { return(0);//已登录 } }