#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:
@@ -10,15 +10,12 @@ public interface IIdentityService
|
||||
Task<UserModel?> FindUserByIdAsync(string id);
|
||||
Task<UserModel?> GetCurrentUserAsync();
|
||||
Task<UserModel?> FindUserByEmailAsync(string id);
|
||||
Task<string?> LoginAsync(string email, string password);
|
||||
Task<UserModel?> GetUserByUserNameAsync(string userName);
|
||||
Task<bool> IsInRoleAsync(string userId, string role);
|
||||
Task<bool> AuthorizeAsync(string userId, string policyName);
|
||||
Task<Result> AddRoleAsync(string userId, string role);
|
||||
Task<IList<string>> GetCurrentUserRolesAsync();
|
||||
|
||||
Task<(Result Result, string UserId)> CreateUserAsync(string userName, string password);
|
||||
|
||||
Task<(Result Result, string UserId)> CreateUserAsync(Userinfo userInfo);
|
||||
|
||||
Task<Result> DeleteUserAsync(string userId);
|
||||
}
|
||||
|
||||
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