Beispiel #1
0
 /// <summary>
 /// 设置token到返回的信息
 /// </summary>
 /// <param name="baseController">http请求上下文</param>
 /// <param name="token">token内容</param>
 public static void SetUserToken(this ScriptBaseController baseController, TokenInfo token, User user)
 {
     baseController.HttpContext.Response.Headers.Add(baseController.CacheKey.TokenName, TokenInfo.TokenToString(token));
     baseController.HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", baseController.CacheKey.TokenName);
     baseController.MemoryCache.SetValue(user.Name, user, token.OverTime);
 }
Beispiel #2
0
 /// <summary>
 /// 获取用户信息
 /// </summary>
 /// <param name="daweiBase"></param>
 /// <returns></returns>
 public static User GetLoginUser(this ScriptBaseController baseController)
 {
     return(baseController.HttpContext.GetLoginUser(baseController.CacheKey, baseController.MemoryCache));
 }