Added ObjectAttribute interface & classes

This commit is contained in:
Max 2024-07-27 12:49:45 +02:00
parent 5341179e94
commit c7d654a0ba
7 changed files with 63 additions and 4 deletions

View File

@ -3,7 +3,7 @@ namespace DotBased.ASP.Auth;
public class BasedAuthConfiguration public class BasedAuthConfiguration
{ {
/// <summary> /// <summary>
/// Allow users to registrate a user account. /// Allow users to registrate.
/// </summary> /// </summary>
public bool AllowRegistration { get; set; } public bool AllowRegistration { get; set; }
//TODO: Callback when a user registers, so the application can handle sending emails or generate a code to complete the registration. //TODO: Callback when a user registers, so the application can handle sending emails or generate a code to complete the registration.

View File

@ -1,3 +1,5 @@
using DotBased.Objects;
namespace DotBased.ASP.Auth.Domains.Auth; namespace DotBased.ASP.Auth.Domains.Auth;
public class RoleModel public class RoleModel
@ -6,4 +8,5 @@ public class RoleModel
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public List<PermissionModel> Permissions { get; set; } = []; public List<PermissionModel> Permissions { get; set; } = [];
public List<DbObjectAttribute<IConvertible>> Attributes { get; set; } = [];
} }

View File

@ -1,4 +1,5 @@
using DotBased.ASP.Auth.Domains.Auth; using DotBased.ASP.Auth.Domains.Auth;
using DotBased.Objects;
namespace DotBased.ASP.Auth.Domains.Identity; namespace DotBased.ASP.Auth.Domains.Identity;
@ -8,4 +9,5 @@ public class GroupModel
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public List<RoleModel> Roles { get; set; } = []; public List<RoleModel> Roles { get; set; } = [];
public List<DbObjectAttribute<IConvertible>> Attributes { get; set; } = [];
} }

View File

@ -1,14 +1,31 @@
using DotBased.ASP.Auth.Domains.Auth;
using DotBased.Objects;
namespace DotBased.ASP.Auth.Domains.Identity; namespace DotBased.ASP.Auth.Domains.Identity;
public class UserModel public class UserModel
{ {
public string UserName { get; set; } = string.Empty; public string UserName { get; set; } = string.Empty;
public string PasswordHash { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string FamilyName { get; set; } = string.Empty; public string FamilyName { get; set; } = string.Empty;
public DateTime Dob { get; set; }
public string Id { get; set; } = Guid.NewGuid().ToString(); public string Id { get; set; } = Guid.NewGuid().ToString();
public string PasswordHash { get; set; } = string.Empty; public bool Enabled { get; set; }
public string[] GroupIds { get; set; } = Array.Empty<string>(); public bool EmailValidated { get; set; }
public string[] Roles { get; set; } = Array.Empty<string>(); public bool PhoneNumberConfirmed { get; set; }
public bool Lockout { get; set; }
public DateTime LockoutEnd { get; set; }
public DateTime CreationStamp { get; set; }
public DateTime SecurityStamp { get; set; }
public DateTime ConcurrencyStamp { get; set; }
public int AccessFailedCount { get; set; }
public bool ExternalAuthentication { get; set; }
public List<GroupModel> Groups { get; set; } = [];
public List<RoleModel> Roles { get; set; } = [];
public List<DbObjectAttribute<IConvertible>> Attributes { get; set; } = [];
} }

View File

@ -0,0 +1,14 @@
using DotBased.Extensions;
namespace DotBased.Objects;
public class DbObjectAttribute<TValueType> : ObjectAttribute<TValueType>
{
public DbObjectAttribute(string key, TValueType value, string owner) : base(key, value)
{
if (owner.IsNullOrWhiteSpace())
throw new ArgumentNullException(nameof(owner), $"The parameter {nameof(owner)} is null or empty! This parameter is required!");
Owner = owner;
}
public string Owner { get; set; }
}

View File

@ -0,0 +1,7 @@
namespace DotBased.Objects;
public interface IObjectAttribute<TValueType>
{
public string Key { get; set; }
public TValueType? Value { get; set; }
}

View File

@ -0,0 +1,16 @@
using DotBased.Extensions;
namespace DotBased.Objects;
public class ObjectAttribute<TValueType> : IObjectAttribute<TValueType>
{
protected ObjectAttribute(string key, TValueType value)
{
if (key.IsNullOrWhiteSpace())
throw new ArgumentNullException(nameof(key), $"The parameter {nameof(key)} is null or empty!");
Key = key;
Value = value;
}
public string Key { get; set; }
public TValueType? Value { get; set; }
}