mirror of
https://github.com/hmaxnl/DotBased.git
synced 2025-01-18 10:04:20 +01:00
Added ObjectAttribute interface & classes
This commit is contained in:
parent
5341179e94
commit
c7d654a0ba
|
@ -3,7 +3,7 @@ namespace DotBased.ASP.Auth;
|
|||
public class BasedAuthConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Allow users to registrate a user account.
|
||||
/// Allow users to registrate.
|
||||
/// </summary>
|
||||
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.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using DotBased.Objects;
|
||||
|
||||
namespace DotBased.ASP.Auth.Domains.Auth;
|
||||
|
||||
public class RoleModel
|
||||
|
@ -6,4 +8,5 @@ public class RoleModel
|
|||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public List<PermissionModel> Permissions { get; set; } = [];
|
||||
public List<DbObjectAttribute<IConvertible>> Attributes { get; set; } = [];
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using DotBased.ASP.Auth.Domains.Auth;
|
||||
using DotBased.Objects;
|
||||
|
||||
namespace DotBased.ASP.Auth.Domains.Identity;
|
||||
|
||||
|
@ -8,4 +9,5 @@ public class GroupModel
|
|||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public List<RoleModel> Roles { get; set; } = [];
|
||||
public List<DbObjectAttribute<IConvertible>> Attributes { get; set; } = [];
|
||||
}
|
|
@ -1,14 +1,31 @@
|
|||
using DotBased.ASP.Auth.Domains.Auth;
|
||||
using DotBased.Objects;
|
||||
|
||||
namespace DotBased.ASP.Auth.Domains.Identity;
|
||||
|
||||
public class UserModel
|
||||
{
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string PasswordHash { 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 FamilyName { get; set; } = string.Empty;
|
||||
public DateTime Dob { get; set; }
|
||||
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
public string[] GroupIds { get; set; } = Array.Empty<string>();
|
||||
public string[] Roles { get; set; } = Array.Empty<string>();
|
||||
public bool Enabled { get; set; }
|
||||
public bool EmailValidated { get; set; }
|
||||
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; } = [];
|
||||
}
|
14
DotBased/Objects/DbObjectAttribute.cs
Normal file
14
DotBased/Objects/DbObjectAttribute.cs
Normal 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; }
|
||||
}
|
7
DotBased/Objects/IObjectAttribute.cs
Normal file
7
DotBased/Objects/IObjectAttribute.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace DotBased.Objects;
|
||||
|
||||
public interface IObjectAttribute<TValueType>
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public TValueType? Value { get; set; }
|
||||
}
|
16
DotBased/Objects/ObjectAttribute.cs
Normal file
16
DotBased/Objects/ObjectAttribute.cs
Normal 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; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user