refactor(core): encapsulate user and refresh token creation with factory methods
This commit is contained in:
@@ -5,7 +5,7 @@ public sealed class RefreshToken : Entity
|
||||
public string Token { get; init; } = string.Empty;
|
||||
public DateTimeOffset ExpiresAt { get; init; }
|
||||
public Guid UserId { get; init; }
|
||||
public User User { get; init; } = new();
|
||||
public User User { get; init; } = User.New();
|
||||
|
||||
private RefreshToken()
|
||||
{
|
||||
|
||||
@@ -6,4 +6,22 @@ public sealed class User : Entity
|
||||
public string HashedPassword { get; init; } = string.Empty;
|
||||
|
||||
public ICollection<RefreshToken> RefreshTokens { get; init; } = [];
|
||||
|
||||
private User()
|
||||
{
|
||||
}
|
||||
|
||||
public static User New()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
public static User From(string username, string hashedPassword)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Username = username,
|
||||
HashedPassword = hashedPassword,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
global using FiscalOS.Core.Data;
|
||||
global using FiscalOS.Core.Data;
|
||||
|
||||
global using FiscalOS.Core.Identity;
|
||||
Reference in New Issue
Block a user