wip
This commit is contained in:
parent
cb9d5e332e
commit
baea64229b
9 changed files with 69 additions and 11 deletions
|
@ -0,0 +1,5 @@
|
|||
using Femto.Common.Domain;
|
||||
|
||||
namespace Femto.Modules.Authentication.Application.Commands;
|
||||
|
||||
public record LoginCommand(string Username, string Password) : ICommand<Guid>;
|
|
@ -0,0 +1,19 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue