public ActionResult <LoginResModel> Manage_BackgroundLogin(LoginViewModel loginModel)
        {
            LoginResModel model            = new LoginResModel();
            var           UserSearchResult = _loginService.VolunteerBackgroundLogin_User(loginModel);

            if (UserSearchResult == null)
            {
                model.IsSuccess                  = false;
                model.baseViewModel.Message      = "用户名不存在或者密码错误";
                model.baseViewModel.ResponseCode = 400;
                //_ILogger.Information("用户名不存在或者密码错误,进入系统失败");
                return(BadRequest(model));
            }
            else
            {
                TokenModelJwt tokenModel = new TokenModelJwt();
                tokenModel.Uid  = Convert.ToInt32(UserSearchResult.Id);
                tokenModel.Role = UserSearchResult.UserName;
                string token = JwtHelper.IssueJwt(tokenModel);

                model.user_session               = UserSearchResult;
                model.IsSuccess                  = true;
                model.baseViewModel.Message      = "存在该用户,查询成功";
                model.baseViewModel.ResponseCode = 200;
                model.token = token;
                //_ILogger.Information("查询用户信息,存在该用户,权限查询成功");

                return(Ok(model));
            }
        }
示例#2
0
 public async Task <IHttpActionResult> Login(LoginReqModel loginModel)
 {
     if (loginModel == null)
     {
         return(BadRequest("请求格式有误"));
     }
     if (loginModel.password == null || loginModel.password.Length == 0 ||
         loginModel.user != "test" || loginModel.password != "test123")
     {
         return(BadRequest("用户密码错误"));
     }
     return(await Task.Run(() =>
     {
         var loginTime = DateTime.Now;
         var token = "qwe123456";
         var res = new LoginResModel()
         {
             UserName = loginModel.user,
             Level = 1,
             Money = 0,
             Token = token
         };
         return SuccessResult(res);
     }));
 }