#oauth changed GoogleController for the jwt flow ( using a common token if we connect from our app or from google )
This commit is contained in:
27
src/Application/Users/Commands/Login.cs
Normal file
27
src/Application/Users/Commands/Login.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.Users.Commands;
|
||||
public record LoginCommand : IRequest<string>
|
||||
{
|
||||
public required string EmailAddress { get; init; }
|
||||
public required string Password { get; init; }
|
||||
}
|
||||
|
||||
public class LoginCommandHandler : IRequestHandler<LoginCommand, string>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
private readonly IIdentityService _identityService;
|
||||
|
||||
public LoginCommandHandler(IApplicationDbContext context, IIdentityService identityService)
|
||||
{
|
||||
_context = context;
|
||||
_identityService = identityService;
|
||||
}
|
||||
|
||||
public async Task<string> Handle(LoginCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var jwt = await _identityService.LoginAsync(request.EmailAddress, request.Password);
|
||||
|
||||
return jwt ?? "Invalid login credentials";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user