Skip to content

Commit

Permalink
FIX: Solving endpoint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fmattioli committed Jul 7, 2024
1 parent 41e3462 commit 60fd243
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Contracts.Common;
using Contracts.Web.Attributes;

using Contracts.Web.Attributes;
using MediatR;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

using TokenManager.Application.Services.Commands.Users;
using TokenManager.Application.Services.Requests.User;
using TokenManager.Application.Services.Responses;
Expand Down Expand Up @@ -45,7 +41,6 @@ public async Task<IActionResult> CreateUser([FromRoute] string tenant, [FromBody
return BadRequest(response);
}


/// <summary>
/// Return a valid JWT token and details about them.
/// </summary>
Expand All @@ -60,12 +55,17 @@ public async Task<IActionResult> CreateUser([FromRoute] string tenant, [FromBody
public async Task<IActionResult> Login([FromBody] LoginUserRequest loginUserRequest, CancellationToken cancellationToken)
{
var result = await _mediator.Send(new LoginUserCommand(loginUserRequest), cancellationToken);

var response = new ResponseResult<TokenResponse>();
if (result.IsSuccess)
{
response.Result = result.Value;
response.DetailMessage = "Token generated with succesfully";
return Created();
}

return BadRequest(result.Error.Description);
response.DetailMessage = result.Error.Description;
return BadRequest(response);
}
}
}

0 comments on commit 60fd243

Please sign in to comment.