feat(core): add password hashing and token generation interfaces
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
namespace FiscalOS.API.Login;
|
||||
|
||||
internal sealed record Response(string AccessToken);
|
||||
internal sealed record Response
|
||||
{
|
||||
public string AccessToken { get; init; }
|
||||
|
||||
private Response(string accessToken)
|
||||
{
|
||||
AccessToken = accessToken;
|
||||
}
|
||||
|
||||
public static Response From(string accessToken)
|
||||
{
|
||||
return new(accessToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FiscalOS.Core.Authentication;
|
||||
|
||||
public interface IPasswordHasher
|
||||
{
|
||||
string Hash(string password);
|
||||
bool Verify(string providedPassword, string hashedPassword);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FiscalOS.Core.Authentication;
|
||||
|
||||
public interface ITokenGenerator
|
||||
{
|
||||
string GenerateAccessToken(User user);
|
||||
RefreshToken GenerateRefreshToken(User user);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public sealed class AppDbContext(IOptions<AppDbContextOptions> ctxOptions) : DbC
|
||||
var connectionString = $"{DataSourceKey}{dbPath}";
|
||||
|
||||
optionsBuilder.UseSqlite(connectionString)
|
||||
.AddInterceptors(new TimestampInterceptor());
|
||||
.AddInterceptors(TimestampInterceptor.New());
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
||||
@@ -4,6 +4,15 @@ namespace FiscalOS.Infra.Data;
|
||||
|
||||
internal sealed class TimestampInterceptor : SaveChangesInterceptor
|
||||
{
|
||||
private TimestampInterceptor()
|
||||
{
|
||||
}
|
||||
|
||||
public static TimestampInterceptor New()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
public override InterceptionResult<int> SavingChanges(DbContextEventData eventData, InterceptionResult<int> result)
|
||||
{
|
||||
UpdateEntities(eventData.Context);
|
||||
|
||||
Reference in New Issue
Block a user