[ADD] Adding models, repositories. Implementing business logic.

This commit is contained in:
max
2024-12-22 02:15:34 +01:00
parent 7ebe1e1752
commit 44e64793b7
12 changed files with 147 additions and 41 deletions

View File

@@ -0,0 +1,25 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityAttribute
{
public AuthorityAttribute(string attributeKey, string bound) : this()
{
AttributeKey = attributeKey;
BoundId = bound;
}
public AuthorityAttribute()
{
}
public string AttributeKey { get; set; } // ClaimType/Authority.attribute.enabled
public string BoundId { get; set; } // Bound to User, Group, Role id
public string? AttributeValue { get; set; }
public string? Type { get; set; } // AspNet.Claim.Role/Property/Data.JSON, Data.Raw, Data.Base64 etc.
public long Version { get; set; }
}

View File

@@ -0,0 +1,26 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityGroup : AuthorityGroup<Guid>
{
public AuthorityGroup(string name) : this()
{
Name = name;
}
public AuthorityGroup()
{
Id = Guid.NewGuid();
CreatedDate = DateTime.Now;
}
}
public abstract class AuthorityGroup<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; }
public string? Name { get; set; }
public long Version { get; set; }
public DateTime CreatedDate { get; set; }
}

View File

@@ -0,0 +1,28 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityRole : AuthorityRole<Guid>
{
public AuthorityRole(string name) : this()
{
Name = name;
}
public AuthorityRole()
{
Id = Guid.NewGuid();
CreatedDate = DateTime.Now;
}
}
public abstract class AuthorityRole<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; }
public string? Name { get; set; }
public long Version { get; set; }
public DateTime CreatedDate { get; set; }
public override string ToString() => Name ?? string.Empty;
}

View File

@@ -1,10 +1,52 @@
using DotBased.AspNet.Authority.Attributes;
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityUser : AuthorityUserBase<Guid>
public class AuthorityUser : AuthorityUser<Guid>
{
public AuthorityUser(string userName) : this()
{
UserName = userName;
}
public AuthorityUser()
{
Id = Guid.NewGuid();
CreatedDate = DateTime.Now;
}
}
public abstract class AuthorityUser<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; }
public bool Enabled { get; set; }
public bool Locked { get; set; }
public DateTime LockedDate { get; set; }
public string? UserName { get; set; }
public string? PasswordHash { get; set; }
public DateTime CreatedDate { get; set; }
public bool TwoFactorEnabled { get; set; }
public long Version { get; set; }
public long SecurityVersion { get; set; }
[Protect]
public string? EmailAddress { get; set; }
public bool EmailConfirmed { get; set; }
[Protect]
public string? PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
public override string ToString() => UserName ?? EmailAddress ?? string.Empty;
}

View File

@@ -1,35 +0,0 @@
using DotBased.AspNet.Authority.Attributes;
namespace DotBased.AspNet.Authority.Models.Authority;
public abstract class AuthorityUserBase<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; }
public bool Enabled { get; set; }
public bool Locked { get; set; }
public string UserName { get; set; }
public string PasswordHash { get; set; }
public DateTime CreatedDate { get; set; }
public bool TwoFactorEnabled { get; set; }
public string ConcurrencyStamp { get; set; }
public string SecurityStamp { get; set; }
[Protect]
public string EmailAddress { get; set; }
public bool EmailConfirmed { get; set; }
[Protect]
public string PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
}