Ejemplo n.º 1
0
 ///作废TokenId用于注销登录
 public ReturnItem <bool> DisableTokenId(DisableTokenIdParameter parameter)
 {
     if (parameter.TokenId == null || parameter.TokenId == "")
     {
         return(new ReturnItem <bool>()
         {
             Code = -1, Msg = "无TokenId", Data = false
         });
     }
     if (parameter.UserId == null || parameter.UserId == "")
     {
         return(new ReturnItem <bool>()
         {
             Code = -1, Msg = "无user", Data = false
         });
     }
     using (UserEntities user = new UserEntities())
     {
         long temp = Convert.ToInt32(parameter.UserId);
         user.U_Token.Where(t => t.TokenID == parameter.TokenId && !t.IsDisabled == true && t.UserID == temp).ToList().ForEach(t => { t.IsDisabled = true; t.DisabledTime = DateTime.Now; });
         user.SaveChanges();
         if (CustomConfigParam.IsUseRedis)
         {
             new RedisClient(CustomConfigParam.RedisDbNumber).KeyDelete("Token:" + parameter.TokenId.Replace("-", ""));
         }
         return(new ReturnItem <bool>()
         {
             Code = 0, Msg = "欢迎再来", Data = true
         });
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 登出操作
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public IHttpActionResult DisableTokenId(DisableTokenIdParameter parameter)
        {
            UserLoginBLL user = new UserLoginBLL();

            return(InspurJson(user.DisableTokenId(parameter), true));
        }