femto-backend/Femto.Modules.Authentication/Application/Commands/Login/LoginCommandHandler.cs
2025-05-12 09:33:07 +02:00

19 lines
No EOL
582 B
C#

using Femto.Modules.Authentication.Data;
using Femto.Modules.Authentication.Models;
using MediatR;
namespace Femto.Modules.Authentication.Application.Commands;
internal class LoginCommandHandler(AuthenticationContext context) : IRequestHandler<LoginCommand, Guid>
{
public async Task<Guid> Handle(LoginCommand request, CancellationToken cancellationToken)
{
var user = new UserIdentity(request.Username);
user.SetPassword(request.Password);
await context.AddAsync(user, cancellationToken);
return user.Id;
}
}