last ...
This commit is contained in:
@@ -84,6 +84,24 @@ namespace xIdentityModels.Dtos {
|
||||
NullValueHandling = NullValueHandling.Ignore)]
|
||||
public XGender Gender { get; set; }
|
||||
|
||||
[JsonProperty (
|
||||
"bio",
|
||||
Required = Required.Default,
|
||||
NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string Bio { get; set; }
|
||||
|
||||
[JsonProperty (
|
||||
"coverImage",
|
||||
Required = Required.Default,
|
||||
NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string CoverImage { get; set; }
|
||||
|
||||
[JsonProperty (
|
||||
"openToSearch",
|
||||
Required = Required.Default,
|
||||
NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool OpenToSearch { get; set; }
|
||||
|
||||
[JsonProperty (
|
||||
"friendshipInfo",
|
||||
Required = Required.Default,
|
||||
|
||||
+118
-64
@@ -9,8 +9,10 @@ using xExceptions.Constants;
|
||||
using xIdentityModels.Constants;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xIdentityModels.Models {
|
||||
public class XUserClaimsInfoDto : XBaseDto {
|
||||
namespace xIdentityModels.Models
|
||||
{
|
||||
public class XUserClaimsInfoDto : XBaseDto
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
public string AccessToken { get; }
|
||||
@@ -28,30 +30,35 @@ namespace xIdentityModels.Models {
|
||||
public bool IsEnabled { get; }
|
||||
public bool EmailConfirmed { get; }
|
||||
public bool PhoneNumberConfirmed { get; }
|
||||
public string Bio { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public bool OpenToSearch { get; set; }
|
||||
public long? ExpiredOn { get; }
|
||||
public long? AuthenticatedOn { get; }
|
||||
public DateTime? BrithDate { get; }
|
||||
public IEnumerable<string> Issuers { get; } = new HashSet<string> ();
|
||||
public IEnumerable<string> Audiences { get; } = new HashSet<string> ();
|
||||
public IEnumerable<string> ClientIds { get; } = new HashSet<string> ();
|
||||
public IEnumerable<string> Scopes { get; } = new HashSet<string> ();
|
||||
public IEnumerable<string> Roles { get; } = new HashSet<string> ();
|
||||
public IEnumerable<string> Issuers { get; } = new HashSet<string>();
|
||||
public IEnumerable<string> Audiences { get; } = new HashSet<string>();
|
||||
public IEnumerable<string> ClientIds { get; } = new HashSet<string>();
|
||||
public IEnumerable<string> Scopes { get; } = new HashSet<string>();
|
||||
public IEnumerable<string> Roles { get; } = new HashSet<string>();
|
||||
#endregion
|
||||
|
||||
//
|
||||
public XUserClaimsInfoDto () { }
|
||||
public XUserClaimsInfoDto() { }
|
||||
|
||||
public XUserClaimsInfoDto (
|
||||
public XUserClaimsInfoDto(
|
||||
string accessToken,
|
||||
string refreshToken,
|
||||
long expiresAt,
|
||||
IEnumerable<Claim> claims
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// refreshToken.IsNullOrEmpty ()
|
||||
if (claims.IsNull () ||
|
||||
accessToken.IsNullOrEmpty ()) {
|
||||
XException.InvalidArgs.Throw ();
|
||||
if (claims.IsNull() ||
|
||||
accessToken.IsNullOrEmpty())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -61,34 +68,62 @@ namespace xIdentityModels.Models {
|
||||
ExpiresAt = expiresAt;
|
||||
|
||||
//
|
||||
if (!claims.IsNull ()) {
|
||||
UserId = claims.FirstOrDefault (c => c.Type == XCustomClaims.UserId)?.Value ?? "";
|
||||
UserName = claims.FirstOrDefault (c => c.Type == XCustomClaims.UserName)?.Value ?? "";
|
||||
FirstName = claims.FirstOrDefault (c => c.Type == XCustomClaims.FirstName)?.Value ?? "";
|
||||
LastName = claims.FirstOrDefault (c => c.Type == XCustomClaims.LastName)?.Value ?? "";
|
||||
Picture = claims.FirstOrDefault (c => c.Type == XCustomClaims.Picture)?.Value ?? "";
|
||||
Email = claims.FirstOrDefault (c => c.Type == XCustomClaims.Email)?.Value ?? null;
|
||||
PhoneNumber = claims.FirstOrDefault (c => c.Type == XCustomClaims.PhoneNumber)?.Value ?? null;
|
||||
if (!claims.IsNull())
|
||||
{
|
||||
//
|
||||
UserId = claims.FirstOrDefault(c => c.Type == XCustomClaims.UserId)?.Value ?? "";
|
||||
UserName = claims.FirstOrDefault(c => c.Type == XCustomClaims.UserName)?.Value ?? "";
|
||||
FirstName = claims.FirstOrDefault(c => c.Type == XCustomClaims.FirstName)?.Value ?? "";
|
||||
LastName = claims.FirstOrDefault(c => c.Type == XCustomClaims.LastName)?.Value ?? "";
|
||||
Picture = claims.FirstOrDefault(c => c.Type == XCustomClaims.Picture)?.Value ?? "";
|
||||
Email = claims.FirstOrDefault(c => c.Type == XCustomClaims.Email)?.Value ?? null;
|
||||
PhoneNumber = claims.FirstOrDefault(c => c.Type == XCustomClaims.PhoneNumber)?.Value ?? null;
|
||||
|
||||
//
|
||||
Bio = claims.FirstOrDefault(c => c.Type == XCustomClaims.Bio)?.Value ?? null;
|
||||
CoverImage = claims.FirstOrDefault(c => c.Type == XCustomClaims.CoverImage)?.Value ?? null;
|
||||
|
||||
//
|
||||
var openToSearchStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.OpenToSearch)?.Value ?? null;
|
||||
if (openToSearchStr.IsNullOrEmpty())
|
||||
{
|
||||
OpenToSearch = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var openToSearch = false;
|
||||
bool.TryParse(openToSearchStr, out openToSearch);
|
||||
|
||||
//
|
||||
OpenToSearch = openToSearch;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Gender ...
|
||||
var genders = ObjectHelper.ToEnumerableKeys<XGender> ();
|
||||
var genderStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.Gender).Value ?? null;
|
||||
if (genderStr.IsNullOrEmpty ()) {
|
||||
var genders = ObjectHelper.ToEnumerableKeys<XGender>();
|
||||
var genderStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.Gender).Value ?? null;
|
||||
if (genderStr.IsNullOrEmpty())
|
||||
{
|
||||
Gender = XGender.Male;
|
||||
} else {
|
||||
Gender = genderStr.GetValue<XGender> ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Gender = genderStr.GetValue<XGender>();
|
||||
}
|
||||
|
||||
//
|
||||
// Handle IsBanned ...
|
||||
var isBannedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.IsBanned).Value ?? null;
|
||||
if (isBannedStr.IsNullOrEmpty ()) {
|
||||
var isBannedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsBanned).Value ?? null;
|
||||
if (isBannedStr.IsNullOrEmpty())
|
||||
{
|
||||
IsBanned = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var isBanned = false;
|
||||
Boolean.TryParse (isBannedStr, out isBanned);
|
||||
Boolean.TryParse(isBannedStr, out isBanned);
|
||||
|
||||
//
|
||||
IsBanned = isBanned;
|
||||
@@ -96,13 +131,16 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle IsEnabled ...
|
||||
var isEnabledStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.IsEnabled).Value ?? null;
|
||||
if (isEnabledStr.IsNullOrEmpty ()) {
|
||||
var isEnabledStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsEnabled).Value ?? null;
|
||||
if (isEnabledStr.IsNullOrEmpty())
|
||||
{
|
||||
IsEnabled = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var isEnabled = false;
|
||||
Boolean.TryParse (isEnabledStr, out isEnabled);
|
||||
Boolean.TryParse(isEnabledStr, out isEnabled);
|
||||
|
||||
//
|
||||
IsEnabled = isEnabled;
|
||||
@@ -110,13 +148,16 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle Email Confirmed ...
|
||||
var emailConfirmedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.EmailVerified).Value ?? null;
|
||||
if (emailConfirmedStr.IsNullOrEmpty ()) {
|
||||
var emailConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.EmailVerified).Value ?? null;
|
||||
if (emailConfirmedStr.IsNullOrEmpty())
|
||||
{
|
||||
EmailConfirmed = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var emailConfirmed = false;
|
||||
Boolean.TryParse (emailConfirmedStr, out emailConfirmed);
|
||||
Boolean.TryParse(emailConfirmedStr, out emailConfirmed);
|
||||
|
||||
//
|
||||
EmailConfirmed = emailConfirmed;
|
||||
@@ -124,13 +165,16 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle PhoneNumber Confirmed ...
|
||||
var phoneNumberConfirmedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.PhoneNumberVerified).Value ?? null;
|
||||
if (phoneNumberConfirmedStr.IsNullOrEmpty ()) {
|
||||
var phoneNumberConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.PhoneNumberVerified).Value ?? null;
|
||||
if (phoneNumberConfirmedStr.IsNullOrEmpty())
|
||||
{
|
||||
PhoneNumberConfirmed = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var phoneNumberConfirmed = false;
|
||||
Boolean.TryParse (phoneNumberConfirmedStr, out phoneNumberConfirmed);
|
||||
Boolean.TryParse(phoneNumberConfirmedStr, out phoneNumberConfirmed);
|
||||
|
||||
//
|
||||
PhoneNumberConfirmed = phoneNumberConfirmed;
|
||||
@@ -138,13 +182,16 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle ExpiredOn ...
|
||||
var expiredOnStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.ExpiredOn).Value ?? null;
|
||||
if (expiredOnStr.IsNullOrEmpty ()) {
|
||||
var expiredOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.ExpiredOn).Value ?? null;
|
||||
if (expiredOnStr.IsNullOrEmpty())
|
||||
{
|
||||
ExpiredOn = null;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
long expiredOn = 0;
|
||||
long.TryParse (expiredOnStr, out expiredOn);
|
||||
long.TryParse(expiredOnStr, out expiredOn);
|
||||
|
||||
//
|
||||
ExpiredOn = expiredOn;
|
||||
@@ -152,13 +199,16 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle AuthenticatedOn ...
|
||||
var authenticatedOnStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.AuthenticatedOn).Value ?? null;
|
||||
if (authenticatedOnStr.IsNullOrEmpty ()) {
|
||||
var authenticatedOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.AuthenticatedOn).Value ?? null;
|
||||
if (authenticatedOnStr.IsNullOrEmpty())
|
||||
{
|
||||
AuthenticatedOn = null;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
long authenticatedOn = 0;
|
||||
long.TryParse (authenticatedOnStr, out authenticatedOn);
|
||||
long.TryParse(authenticatedOnStr, out authenticatedOn);
|
||||
|
||||
//
|
||||
AuthenticatedOn = authenticatedOn;
|
||||
@@ -166,29 +216,33 @@ namespace xIdentityModels.Models {
|
||||
|
||||
//
|
||||
// Handle BrithDate ...
|
||||
var brithDateStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.BrithDate)?.Value ?? "";
|
||||
if (brithDateStr.IsNullOrEmpty ()) {
|
||||
var brithDateStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.BrithDate)?.Value ?? "";
|
||||
if (brithDateStr.IsNullOrEmpty())
|
||||
{
|
||||
// BrithDate = null;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
DateTime bDate;
|
||||
DateTime.TryParse (brithDateStr, out bDate);
|
||||
DateTime.TryParse(brithDateStr, out bDate);
|
||||
|
||||
//
|
||||
BrithDate = bDate;
|
||||
}
|
||||
|
||||
//
|
||||
Issuers = claims.Where (c => c.Type == XCustomClaims.Issuer) ?
|
||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
||||
Audiences = claims.Where (c => c.Type == XCustomClaims.Audience) ?
|
||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
||||
ClientIds = claims.Where (c => c.Type == XCustomClaims.ClientId) ?
|
||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
||||
Scopes = claims.Where (c => c.Type == XCustomClaims.Scope) ?
|
||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
||||
Roles = claims.Where (c => c.Type == XCustomClaims.Role) ?
|
||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
||||
// Collections ...
|
||||
Issuers = claims.Where(c => c.Type == XCustomClaims.Issuer)?
|
||||
.Select(c => c.Value) ?? new HashSet<string>();
|
||||
Audiences = claims.Where(c => c.Type == XCustomClaims.Audience)?
|
||||
.Select(c => c.Value) ?? new HashSet<string>();
|
||||
ClientIds = claims.Where(c => c.Type == XCustomClaims.ClientId)?
|
||||
.Select(c => c.Value) ?? new HashSet<string>();
|
||||
Scopes = claims.Where(c => c.Type == XCustomClaims.Scope)?
|
||||
.Select(c => c.Value) ?? new HashSet<string>();
|
||||
Roles = claims.Where(c => c.Type == XCustomClaims.Role)?
|
||||
.Select(c => c.Value) ?? new HashSet<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ using Microsoft.AspNetCore.Identity;
|
||||
using xIdentityModels.Constants;
|
||||
using xIdentityModels.Navigations;
|
||||
|
||||
namespace xIdentityModels {
|
||||
namespace xIdentityModels
|
||||
{
|
||||
/// <summary>
|
||||
/// represnt a User of System
|
||||
/// </summary>
|
||||
public partial class XUser : IdentityUser {
|
||||
public partial class XUser : IdentityUser
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
/// <summary>
|
||||
@@ -18,14 +20,14 @@ namespace xIdentityModels {
|
||||
/// </summary>
|
||||
/// <value>user's FirstName</value>
|
||||
[Required]
|
||||
[StringLength (50)]
|
||||
[StringLength(50)]
|
||||
public string FirstName { get; set; }
|
||||
/// <summary>
|
||||
/// LastName
|
||||
/// </summary>
|
||||
/// <value>user's LastName</value>
|
||||
[Required]
|
||||
[StringLength (100)]
|
||||
[StringLength(100)]
|
||||
public string LastName { get; set; }
|
||||
/// <summary>
|
||||
/// User is Enabled or not
|
||||
@@ -71,6 +73,21 @@ namespace xIdentityModels {
|
||||
/// <value>user's Gender</value>
|
||||
[Required]
|
||||
public XGender Gender { get; set; }
|
||||
/// <summary>
|
||||
/// User Biography ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Bio { get; set; }
|
||||
/// <summary>
|
||||
/// User Bio Cover Image ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string CoverImage { get; set; }
|
||||
/// <summary>
|
||||
/// Can Discover User ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public bool OpenToSearch { get; set; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
@@ -80,34 +97,34 @@ namespace xIdentityModels {
|
||||
/// </summary>
|
||||
/// <typeparam name="XDevice"><see>XDevice</see></typeparam>
|
||||
/// <returns>a Collection of all assigned Devices to User</returns>
|
||||
[InverseProperty ("User")]
|
||||
public virtual ICollection<XDevice> Devices { get; set; } = new HashSet<XDevice> ();
|
||||
[InverseProperty ("User")]
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<XDevice> Devices { get; set; } = new HashSet<XDevice>();
|
||||
/// <summary>
|
||||
/// User's Avatars
|
||||
/// </summary>
|
||||
/// <typeparam name="XProfileImage"><see>XProfileImage</see></typeparam>
|
||||
/// <returns>a Collection of all assigned Avatars to User</returns>
|
||||
public virtual ICollection<XProfileImage> Avatars { get; set; } = new HashSet<XProfileImage> ();
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<XProfileImage> Avatars { get; set; } = new HashSet<XProfileImage>();
|
||||
/// <summary>
|
||||
/// User's Followers
|
||||
/// </summary>
|
||||
/// <typeparam name="XFriendshipFollower"><see>XFriendshipFollower</see></typeparam>
|
||||
/// <returns>a Collection of all User's Followers</returns>
|
||||
[InverseProperty ("User")]
|
||||
public virtual ICollection<XFriendshipFollower> Followers { get; set; } = new HashSet<XFriendshipFollower> ();
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<XFriendshipFollower> Followers { get; set; } = new HashSet<XFriendshipFollower>();
|
||||
/// <summary>
|
||||
/// User's Followings
|
||||
/// </summary>
|
||||
/// <typeparam name="XFriendshipFollowing"><see>XFriendshipFollowing</see></typeparam>
|
||||
/// <returns>a Collection of all User's Followings</returns>
|
||||
[InverseProperty ("User")]
|
||||
public virtual ICollection<XFriendshipFollowing> Followings { get; set; } = new HashSet<XFriendshipFollowing> ();
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<XFriendshipFollowing> Followings { get; set; } = new HashSet<XFriendshipFollowing>();
|
||||
/// <summary>
|
||||
/// User's Roles
|
||||
/// </summary>
|
||||
/// <returns>a Collection of all User's Roles in System</returns>
|
||||
public virtual ICollection<IdentityUserRole<string>> Roles { get; set; } = new HashSet<IdentityUserRole<string>> ();
|
||||
public virtual ICollection<IdentityUserRole<string>> Roles { get; set; } = new HashSet<IdentityUserRole<string>>();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user