diff options
Diffstat (limited to 'server/src/Data')
| -rw-r--r-- | server/src/Data/Database/ApiAccessToken.cs | 50 | ||||
| -rw-r--r-- | server/src/Data/Database/Base.cs | 20 | ||||
| -rw-r--r-- | server/src/Data/Database/BaseWithOwner.cs | 20 | ||||
| -rw-r--r-- | server/src/Data/Database/Customer.cs | 5 | ||||
| -rw-r--r-- | server/src/Data/Database/User.cs | 55 |
5 files changed, 74 insertions, 76 deletions
diff --git a/server/src/Data/Database/ApiAccessToken.cs b/server/src/Data/Database/ApiAccessToken.cs index a9cf0bc..9582869 100644 --- a/server/src/Data/Database/ApiAccessToken.cs +++ b/server/src/Data/Database/ApiAccessToken.cs @@ -2,30 +2,30 @@ namespace IOL.GreatOffice.Api.Data.Database; public class ApiAccessToken : Base { - public User User { get; set; } - public DateTime ExpiryDate { get; set; } - public bool AllowRead { get; set; } - public bool AllowCreate { get; set; } - public bool AllowUpdate { get; set; } - public bool AllowDelete { get; set; } - public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; - public ApiAccessTokenDto AsDto => new(this); + public User User { get; set; } + public DateTime ExpiryDate { get; set; } + public bool AllowRead { get; set; } + public bool AllowCreate { get; set; } + public bool AllowUpdate { get; set; } + public bool AllowDelete { get; set; } + public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; + public ApiAccessTokenDto AsDto => new(this); - public class ApiAccessTokenDto - { - public ApiAccessTokenDto(ApiAccessToken source) { - ExpiryDate = source.ExpiryDate; - AllowRead = source.AllowRead; - AllowCreate = source.AllowCreate; - AllowUpdate = source.AllowUpdate; - AllowDelete = source.AllowDelete; - } + public class ApiAccessTokenDto + { + public ApiAccessTokenDto(ApiAccessToken source) { + ExpiryDate = source.ExpiryDate; + AllowRead = source.AllowRead; + AllowCreate = source.AllowCreate; + AllowUpdate = source.AllowUpdate; + AllowDelete = source.AllowDelete; + } - public DateTime ExpiryDate { get; set; } - public bool AllowRead { get; set; } - public bool AllowCreate { get; set; } - public bool AllowUpdate { get; set; } - public bool AllowDelete { get; set; } - public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; - } -} + public DateTime ExpiryDate { get; set; } + public bool AllowRead { get; set; } + public bool AllowCreate { get; set; } + public bool AllowUpdate { get; set; } + public bool AllowDelete { get; set; } + public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; + } +}
\ No newline at end of file diff --git a/server/src/Data/Database/Base.cs b/server/src/Data/Database/Base.cs index 7e8591e..ae9efa2 100644 --- a/server/src/Data/Database/Base.cs +++ b/server/src/Data/Database/Base.cs @@ -2,14 +2,14 @@ namespace IOL.GreatOffice.Api.Data.Database; public class Base { - protected Base() { - Id = Guid.NewGuid(); - CreatedAt = AppDateTime.UtcNow; - } + protected Base() { + Id = Guid.NewGuid(); + CreatedAt = AppDateTime.UtcNow; + } - public Guid Id { get; init; } - public DateTime CreatedAt { get; init; } - public DateTime? ModifiedAt { get; private set; } - public bool Deleted { get; set; } - public void Modified() => ModifiedAt = AppDateTime.UtcNow; -} + public Guid Id { get; init; } + public DateTime CreatedAt { get; init; } + public DateTime? ModifiedAt { get; private set; } + public bool Deleted { get; set; } + public void Modified() => ModifiedAt = AppDateTime.UtcNow; +}
\ No newline at end of file diff --git a/server/src/Data/Database/BaseWithOwner.cs b/server/src/Data/Database/BaseWithOwner.cs index 8c54aa2..1eb99f4 100644 --- a/server/src/Data/Database/BaseWithOwner.cs +++ b/server/src/Data/Database/BaseWithOwner.cs @@ -5,15 +5,15 @@ namespace IOL.GreatOffice.Api.Data.Database; /// </summary> public class BaseWithOwner : Base { - protected BaseWithOwner() { } + protected BaseWithOwner() { } - protected BaseWithOwner(Guid userId) { - UserId = userId; - } + protected BaseWithOwner(Guid userId) { + UserId = userId; + } - public Guid? UserId { get; set; } - public Guid? TenantId { get; init; } - public Guid? ModifiedById { get; init; } - public Guid? CreatedById { get; init; } - public Guid? DeletedById { get; init; } -} + public Guid? UserId { get; set; } + public Guid? TenantId { get; init; } + public Guid? ModifiedById { get; init; } + public Guid? CreatedById { get; init; } + public Guid? DeletedById { get; init; } +}
\ No newline at end of file diff --git a/server/src/Data/Database/Customer.cs b/server/src/Data/Database/Customer.cs index 7e83c00..c6b06a4 100644 --- a/server/src/Data/Database/Customer.cs +++ b/server/src/Data/Database/Customer.cs @@ -2,6 +2,5 @@ namespace IOL.GreatOffice.Api.Data.Database; public class Customer : BaseWithOwner { - public string Name { get; set; } - -} + public string Name { get; set; } +}
\ No newline at end of file diff --git a/server/src/Data/Database/User.cs b/server/src/Data/Database/User.cs index 1ef144c..9db5d35 100644 --- a/server/src/Data/Database/User.cs +++ b/server/src/Data/Database/User.cs @@ -2,37 +2,36 @@ namespace IOL.GreatOffice.Api.Data.Database; public class User : Base { - public User() { } + public User() { } - public User(string username) { - Username = username; - } + public User(string username) { + Username = username; + } - public string FirstName { get; set; } - public string LastName { get; set; } - public string Email { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public ICollection<Tenant> Tenants { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string Email { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public ICollection<Tenant> Tenants { get; set; } + public string DisplayName() { + if (FirstName.HasValue() && LastName.HasValue()) return FirstName + " " + LastName; + return FirstName.HasValue() ? FirstName : Email; + } - public string DisplayName() { - if (FirstName.HasValue() && LastName.HasValue()) return FirstName + " " + LastName; - return FirstName.HasValue() ? FirstName : Email; - } + public void HashAndSetPassword(string password) { + Password = PasswordHelper.HashPassword(password); + } - public void HashAndSetPassword(string password) { - Password = PasswordHelper.HashPassword(password); - } + public bool VerifyPassword(string password) { + return PasswordHelper.Verify(password, Password); + } - public bool VerifyPassword(string password) { - return PasswordHelper.Verify(password, Password); - } - - public IEnumerable<Claim> DefaultClaims() { - return new Claim[] { - new(AppClaims.USER_ID, Id.ToString()), - new(AppClaims.NAME, Username), - }; - } -} + public IEnumerable<Claim> DefaultClaims() { + return new Claim[] { + new(AppClaims.USER_ID, Id.ToString()), + new(AppClaims.NAME, Username), + }; + } +}
\ No newline at end of file |
