feat(core): add models for institution
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
namespace FiscalOS.Core.Accounts;
|
||||||
|
|
||||||
|
public sealed class Institution : Entity
|
||||||
|
{
|
||||||
|
public Guid UserId { get; init; }
|
||||||
|
public string Name { get; init; } = string.Empty;
|
||||||
|
public InstitutionMetadata Metadata { get; init; } = null!;
|
||||||
|
|
||||||
|
private Institution()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Institution From(string name, InstitutionMetadata metadata)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(name);
|
||||||
|
ArgumentNullException.ThrowIfNull(metadata);
|
||||||
|
|
||||||
|
return new Institution()
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Metadata = metadata
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace FiscalOS.Core.Accounts;
|
||||||
|
|
||||||
|
public abstract class InstitutionMetadata : Entity
|
||||||
|
{
|
||||||
|
private readonly string _type;
|
||||||
|
|
||||||
|
public string Type => _type;
|
||||||
|
|
||||||
|
public Guid InstitutionId { get; init; }
|
||||||
|
|
||||||
|
protected InstitutionMetadata(string type)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,17 @@ namespace FiscalOS.Core.Identity;
|
|||||||
|
|
||||||
public sealed class User : Entity
|
public sealed class User : Entity
|
||||||
{
|
{
|
||||||
private readonly List<RefreshToken> _refreshTokens = [];
|
|
||||||
|
|
||||||
public string Username { get; init; } = string.Empty;
|
public string Username { get; init; } = string.Empty;
|
||||||
public string HashedPassword { get; init; } = string.Empty;
|
public string HashedPassword { get; init; } = string.Empty;
|
||||||
public string EncryptionKeyId { get; init; } = string.Empty;
|
public string EncryptionKeyId { get; init; } = string.Empty;
|
||||||
public string EncryptedDataKey { get; init; } = string.Empty;
|
public string EncryptedDataKey { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
private readonly List<RefreshToken> _refreshTokens = [];
|
||||||
public IEnumerable<RefreshToken> RefreshTokens => _refreshTokens;
|
public IEnumerable<RefreshToken> RefreshTokens => _refreshTokens;
|
||||||
|
|
||||||
|
private readonly List<Institution> _institutions = [];
|
||||||
|
public IEnumerable<Institution> Institutions => _institutions;
|
||||||
|
|
||||||
private User()
|
private User()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -41,4 +43,11 @@ public sealed class User : Entity
|
|||||||
|
|
||||||
_refreshTokens.Add(refreshToken);
|
_refreshTokens.Add(refreshToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddInstitution(Institution institution)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(institution);
|
||||||
|
|
||||||
|
_institutions.Add(institution);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
global using FiscalOS.Core.Accounts;
|
||||||
global using FiscalOS.Core.Data;
|
global using FiscalOS.Core.Data;
|
||||||
global using FiscalOS.Core.Identity;
|
global using FiscalOS.Core.Identity;
|
||||||
global using FiscalOS.Core.Security;
|
global using FiscalOS.Core.Security;
|
||||||
Reference in New Issue
Block a user