public IActionResult GetToken([FromBody] LoginRequestDto login) { var state = _accountService.Login(login.UserName, login.Password, login.IsDomainAccount); // var state =1; if (state == -1) { return(Ok(new ResponseDto(StatusCodeEnum.AccountError, "账号不存在"))); } if (state == -2) { return(Ok(new ResponseDto(StatusCodeEnum.AccountError, "账号密码错误"))); } var tokenString = _tokenService.WriteToken(new AccountModel() { UserName = login.UserName }); return(Ok(new DataResponseDto() { Data = new TokenResponseDto { Token = tokenString, ExpireIn = 60 * 60 } })); }
public IActionResult GetToken([FromBody] LoginRequestViewModel loginRequestDto) { var login = Mapper.Map <LoginDto>(loginRequestDto); var state = _userService.Login(login); if (state == -1 || state == -2) { return(Ok(new ResponseViewModel(StatusCodeEnum.AccountError, "账号或密码错误"))); } var tokenString = _tokenService.WriteToken(new UserModel() { DomainAccount = loginRequestDto.Account }); return(Ok(new DataResponseViewModel() { Data = new { errorMessage = "", token = tokenString } })); }