Files
fiscalos/src/FiscalOS.Core/Identity/User.cs
T

44 lines
1.1 KiB
C#
Raw Normal View History

namespace FiscalOS.Core.Identity;
2026-02-01 06:13:08 -06:00
public sealed class User : Entity
2026-02-01 06:13:08 -06:00
{
private readonly List<RefreshToken> _refreshTokens = [];
2026-02-01 08:07:23 -06:00
public string Username { get; init; } = string.Empty;
public string HashedPassword { get; init; } = string.Empty;
public string EncryptionKeyId { get; init; } = string.Empty;
public string EncryptedDataKey { get; init; } = string.Empty;
2026-02-01 08:07:23 -06:00
public IEnumerable<RefreshToken> RefreshTokens => _refreshTokens;
private User()
{
}
public static User New()
{
return new();
}
public static User From(string username, string hashedPassword, EncryptedDataKey encryptedDataKey)
{
ArgumentNullException.ThrowIfNull(username);
ArgumentNullException.ThrowIfNull(hashedPassword);
ArgumentNullException.ThrowIfNull(encryptedDataKey);
return new()
{
Username = username,
HashedPassword = hashedPassword,
EncryptedDataKey = encryptedDataKey.EncryptedKey,
EncryptionKeyId = encryptedDataKey.KeyIdUsed,
};
}
public void AddRefreshToken(RefreshToken refreshToken)
{
ArgumentNullException.ThrowIfNull(refreshToken);
_refreshTokens.Add(refreshToken);
}
2026-02-01 06:13:08 -06:00
}