first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SequenceAuth.Example.Features.Auth;
|
||||
|
||||
namespace SequenceAuth.Example.Controllers;
|
||||
|
||||
public class AuthController(IMediator mediator) : ApiControllerBase
|
||||
{
|
||||
public record LoginRequest(string Username);
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Login([FromBody] LoginRequest request)
|
||||
{
|
||||
var result = await mediator.Send(new LoginCommand(request.Username));
|
||||
return Ok(result.User);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
await mediator.Send(new LogoutCommand());
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user