update swagger implementation
This commit is contained in:
@@ -19,6 +19,7 @@ public class AuthController : ControllerBase
|
||||
/// Authenticates a user and returns a JWT with role claims.
|
||||
/// </summary>
|
||||
[HttpPost("login")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(ApiResponse<LoginResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status422UnprocessableEntity)]
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequest req)
|
||||
@@ -32,16 +33,13 @@ public class AuthController : ControllerBase
|
||||
/// </summary>
|
||||
[HttpGet("me")]
|
||||
[Authorize]
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiResponse<UserProfileResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status401Unauthorized)]
|
||||
public async Task<IActionResult> Me()
|
||||
{
|
||||
var userId = Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
||||
var user = await _auth.GetCurrentUserAsync(userId);
|
||||
return Ok(ApiResponse<object>.Ok(new
|
||||
{
|
||||
user.Id, user.Username, user.FullName,
|
||||
role = user.Role.ToDbString()
|
||||
}));
|
||||
return Ok(ApiResponse<UserProfileResponse>.Ok(new UserProfileResponse(
|
||||
user.Id, user.Username, user.FullName, user.Role.ToDbString())));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user