public virtual ISessionKey Current() { try { ISessionKey user = GetCallContextValue("FBState") as ISessionKey; if (user == null) { if (user != null) { return(user); } user = new ISessionKey(); var cookie = CookieHelper.GetCookie(SYSConstants.LoginJWTKey); // Session build user = StateChecker.CheckAuthString(cookie); // StateCheck 验证当前登录状态 todo // Add Context SetCallContextValue("FBState", user); } // 这里可以做线程缓存处理 ?这里需要check校验? 分两步 第一步bulid 然后校验 return(user); } catch (Exception ex) { //return new ISessionKey(); throw new Exception(ex.Message); } }
public void EmptyUser(string uid) { ISessionKey user = new ISessionKey(); user.UserID = uid; StateChecker.RemoveOnlineUser(user); }
public void AddCurrent(ISessionKey user) { // 创建服务器端令牌 user.Token = StateChecker.CreateServerStateToken(user); // 写入cookie CookieHelper.WriteCookie(SYSConstants.LoginJWTKey, StateChecker.CreateJWTToken(user)); }
/// <summary> /// 是否为有效的JWTtoken /// </summary> /// <returns></returns> public string IsAuthJWT() { try { var cookie = CookieHelper.GetCookie(SYSConstants.LoginJWTKey); StateChecker.CheckAuthString(cookie); return(""); } catch (Exception ex) { return(ex.Message); } }
public void EmptyCurrent() { ISessionKey user = GetCallContextValue("FBState") as ISessionKey; if (user != null) { StateChecker.RemoveOnlineUser(user); } // 清除cookie SetCallContextValue("FBState", null); CookieHelper.DelCookie(SYSConstants.LoginJWTKey); }