/// <summary> /// 写入登录信息 /// </summary> /// <param name="user">成员信息</param> public virtual void AddCurrent(IManageUser user) { try { if (LoginProvider == "Cookie") { CookieHelper.WriteCookie(LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user)), 6000); } else { SessionHelper.Add(LoginUserKey, DESEncrypt.Encrypt(JsonConvert.SerializeObject(user))); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 当前用户 /// </summary> /// <returns></returns> public virtual IManageUser Current() { IManageUser user = new IManageUser(); try { if (LoginProvider == "Cookie") { user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(CookieHelper.GetCookie(LoginUserKey))); } else { user = JsonConvert.DeserializeObject <IManageUser>(DESEncrypt.Decrypt(SessionHelper.Get(LoginUserKey).ToString())); } } catch { throw new Exception("登录信息超时,请重新登录。"); } return(user); }