Adds the MediatR package and wires AddMediatR in DI. Replaces IAuthService/AuthService with LoginCommand/LoginHandler, the pattern the remaining modules will follow.
20 lines
518 B
C#
20 lines
518 B
C#
using MediatR;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Mws.Application.Auth;
|
|
|
|
namespace Mws.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/auth")]
|
|
[AllowAnonymous]
|
|
public class AuthController(ISender sender) : ControllerBase
|
|
{
|
|
[HttpPost("login")]
|
|
public async Task<ActionResult<LoginResponse>> Login([FromBody] LoginRequest request, CancellationToken ct)
|
|
{
|
|
var response = await sender.Send(new LoginCommand(request), ct);
|
|
return Ok(response);
|
|
}
|
|
}
|