Template
Feature(Auth): Add Login and Refresh Token
This commit is contained in:
1 parent
bd7e505432
commit
dcc2e99bb1
20 files changed
+252
-20
No files matched your search
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RT.Application.Services.Contract;
|
||||
using RT.Domain.DTOs.Auth;
|
||||
|
||||
namespace RT.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/auth")]
|
||||
public class AuthController(IAuthService authService) : ControllerBase
|
||||
{
|
||||
[HttpPost("login")]
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequestDto dto, CancellationToken ct)
|
||||
{
|
||||
var result = await authService.LoginAsync(dto, ct);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("refresh")]
|
||||
public async Task<IActionResult> Refresh([FromBody] RefreshRequestDto dto, CancellationToken ct)
|
||||
{
|
||||
var result = await authService.RefreshAsync(dto, ct);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("revoke")]
|
||||
public async Task<IActionResult> Revoke([FromBody] RefreshRequestDto dto, CancellationToken ct)
|
||||
{
|
||||
await authService.RevokeAsync(dto, ct);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user