示例#1
0
        public JsonResponse SignIn([FromBody] SignInDto dto)
        {
            if (dto.Email == null || dto.Password == null || dto.Verify == null || dto.VerifyId == null)
            {
                return(BadResponse("参数提供不完整"));
            }
            //判断验证码是否输入正确
            if (!TokenHelper.CheckVerify(dto.VerifyId, dto.Verify))
            {
                return(BadResponse("验证码错误"));
            }
            //检查用户名密码是否正确
            UserInfo model = new UserInfo();

            model = UserInfoBll.GetModelByEmail(dto.Email);
            if (model == null)
            {
                return(BadResponse("用户不存在", null));
            }
            //检查用户是否登录,若有登录信息则刷新时间
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(model.Id))
            {
                LoginState loginState = new LoginState
                {
                    UserId    = model.Id,
                    StartTime = DateTime.Now
                };
                LoginStateBll.Insert(loginState);
            }
            return(OkResponse(null));
        }
示例#2
0
 /// <summary>
 /// 刷新用户登录状态
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 public static void WriteLoginStateTokenByUserId(string UserId)
 {
     //若已登录,则刷新时间
     if (!CheckLoginStateByUserId(UserId))
     {
         LoginState loginState = new LoginState
         {
             UserId    = UserId,
             StartTime = DateTime.Now
         };
         LoginStateBll.Insert(loginState);
     }
 }