public async Task <IActionResult> CreateToken([FromBody] CreateTokenRequest request) { var input = new AuthenticationInput(request.UserName, request.Password); await _useCase.Execute(input); return(_presenter.ViewModel); }
public IActionResult CreateToken([FromBody] CreateTokenRequest request) { try { var input = new AuthenticationInput(request.UserName, request.Password); var user = _useCase.Execute(input); var token = _tokenService.CreateToken(user); var response = new CreateTokenResponse { Token = new JwtSecurityTokenHandler().WriteToken(token), Expires = token.ValidTo }; return(Created("https://paella.com", response)); } catch (System.Exception) { return(BadRequest()); } }