| 123456789101112131415161718192021222324252627282930313233343536 |
- using MediatR;
- using Web.Api.Extensions;
- using Web.Api.Common;
- namespace Web.Api.Endpoints.Auth;
- internal sealed class Login : IEndpoint
- {
- public sealed record Request(
- string Email,
- string Password
- );
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/auth/login", async (
- Request request,
- ISender sender,
- CancellationToken ct
- ) => {
- var command = new Application.Features.Auth.Login.Command(
- request.Email,
- request.Password
- );
- var result = await sender.Send(command, ct);
- return result.Match(
- Results.Ok,
- CustomResults.Problem
- );
- })
- .WithTags("Auth")
- .AllowAnonymous();
- }
- }
|