feat(api): integrate infra and implement password verification on login
This commit is contained in:
@@ -6,7 +6,11 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FiscalOS.Core\FiscalOS.Core.csproj" />
|
||||
<ProjectReference Include="..\FiscalOS.Infra\FiscalOS.Infra.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
using FiscalOS.API.Data;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddValidation();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.ConfigureOptions<AppDbContextOptionsSetup>();
|
||||
builder.Services.AddDbContext<AppDbContext>();
|
||||
builder.Services.AddHostedService<MigrationService>();
|
||||
builder.Services.AddInfrastructure();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
|
||||
global using FiscalOS.API.Data;
|
||||
global using FiscalOS.API.Identity;
|
||||
global using FiscalOS.API.Login;
|
||||
global using FiscalOS.Infra.Data;
|
||||
global using FiscalOS.Infra.DependencyInjection;
|
||||
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.EntityFrameworkCore;
|
||||
global using Microsoft.Extensions.Options;
|
||||
global using Microsoft.EntityFrameworkCore;
|
||||
Reference in New Issue
Block a user