public IActionResult Authenticate(GenerateTokenRequestDto model) { var response = _userService.Authenticate(model); if (response == null) { return(BadRequest(new { message = "Username or password is incorrect" })); } return(Ok(response)); }
public GenerateTokenResponseDto Authenticate(GenerateTokenRequestDto model) { //Auntenticando usuário var user = _users.SingleOrDefault(x => x.Username == model.Username && x.Password == model.Password); if (user == null) { return(null); } //Carregando as informações para o response var token = _tokenService.GenerateJwtToken(user); var validTo = _tokenService.GetExpireTime(token); return(new GenerateTokenResponseDto(user, token, validTo)); }