Template
32 lines
905 B
C#
32 lines
905 B
C#
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();
|
|
}
|
|
}
|