using MediatR; using Modules.Account.Application.Gateways; using Modules.Account.Domain.Gateways; namespace Modules.Account.Application.Queries; public class GetAccountQuery : IRequest { public string Email { get; set; } = default!; public string Password { get; set; } = default!; } public class GetAccountQueryHandler(IAccountGateway accountGateway, IPasswordHasher passwordHasher) : IRequestHandler { const string error = "Invalid email or password"; public async Task Handle(GetAccountQuery request, CancellationToken cancellationToken) { var account = await accountGateway.TryGetByEmail(request.Email); if (account == null) throw new Exception(error); if (passwordHasher.VerifyPassword(new Domain.Entities.Account(account.Id, account.Email, account.HashedPassword), request.Password)) throw new Exception(error); return account; } }