[ADD] Adding models, repositories. Implementing business logic.
This commit is contained in:
@@ -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; }
|
||||
}
|
26
DotBased.AspNet.Authority/Models/Authority/AuthorityGroup.cs
Normal file
26
DotBased.AspNet.Authority/Models/Authority/AuthorityGroup.cs
Normal 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; }
|
||||
}
|
28
DotBased.AspNet.Authority/Models/Authority/AuthorityRole.cs
Normal file
28
DotBased.AspNet.Authority/Models/Authority/AuthorityRole.cs
Normal 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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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; }
|
||||
|
||||
}
|
Reference in New Issue
Block a user