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>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FiscalOS.Core\FiscalOS.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\FiscalOS.Infra\FiscalOS.Infra.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
using FiscalOS.Core.Identity;
|
||||||
|
|
||||||
namespace FiscalOS.API.Login;
|
namespace FiscalOS.API.Login;
|
||||||
|
|
||||||
internal static class Endpoint
|
internal static class Endpoint
|
||||||
@@ -11,7 +14,8 @@ internal static class Endpoint
|
|||||||
|
|
||||||
private static async Task<IResult> HandleAsync(
|
private static async Task<IResult> HandleAsync(
|
||||||
[FromBody] LoginRequest loginRequest,
|
[FromBody] LoginRequest loginRequest,
|
||||||
[FromServices] AppDbContext appDbContext
|
[FromServices] AppDbContext appDbContext,
|
||||||
|
[FromServices] IPasswordHasher passwordHasher
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// TODO: Implement actual auth flow
|
// TODO: Implement actual auth flow
|
||||||
@@ -37,6 +41,13 @@ internal static class Endpoint
|
|||||||
return Results.Unauthorized();
|
return Results.Unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isCorrectPassword = passwordHasher.Verify(loginRequest.Password, user.HashedPassword);
|
||||||
|
|
||||||
|
if (isCorrectPassword is false)
|
||||||
|
{
|
||||||
|
return Results.Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
return Results.Ok();
|
return Results.Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
using FiscalOS.API.Data;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddValidation();
|
builder.Services.AddValidation();
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddOpenApi();
|
||||||
|
|
||||||
builder.Services.ConfigureOptions<AppDbContextOptionsSetup>();
|
builder.Services.AddInfrastructure();
|
||||||
builder.Services.AddDbContext<AppDbContext>();
|
|
||||||
builder.Services.AddHostedService<MigrationService>();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
global using System.ComponentModel.DataAnnotations;
|
global using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
global using FiscalOS.API.Data;
|
|
||||||
global using FiscalOS.API.Identity;
|
|
||||||
global using FiscalOS.API.Login;
|
global using FiscalOS.API.Login;
|
||||||
|
global using FiscalOS.Infra.Data;
|
||||||
|
global using FiscalOS.Infra.DependencyInjection;
|
||||||
|
|
||||||
global using Microsoft.AspNetCore.Mvc;
|
global using Microsoft.AspNetCore.Mvc;
|
||||||
global using Microsoft.EntityFrameworkCore;
|
global using Microsoft.EntityFrameworkCore;
|
||||||
global using Microsoft.Extensions.Options;
|
|
||||||
Reference in New Issue
Block a user