feat(api): integrate infra and implement password verification on login
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
|
||||
using FiscalOS.Core.Identity;
|
||||
|
||||
namespace FiscalOS.API.Login;
|
||||
|
||||
internal static class Endpoint
|
||||
@@ -11,7 +14,8 @@ internal static class Endpoint
|
||||
|
||||
private static async Task<IResult> HandleAsync(
|
||||
[FromBody] LoginRequest loginRequest,
|
||||
[FromServices] AppDbContext appDbContext
|
||||
[FromServices] AppDbContext appDbContext,
|
||||
[FromServices] IPasswordHasher passwordHasher
|
||||
)
|
||||
{
|
||||
// TODO: Implement actual auth flow
|
||||
@@ -37,6 +41,13 @@ internal static class Endpoint
|
||||
return Results.Unauthorized();
|
||||
}
|
||||
|
||||
var isCorrectPassword = passwordHasher.Verify(loginRequest.Password, user.HashedPassword);
|
||||
|
||||
if (isCorrectPassword is false)
|
||||
{
|
||||
return Results.Unauthorized();
|
||||
}
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user