This commit is contained in:
2025-12-23 00:07:55 +03:30
parent f8e07ed23b
commit 23e68de1ef
3 changed files with 166 additions and 77 deletions
+18
View File
@@ -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,
+75 -21
View File
@@ -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,6 +30,9 @@ 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; }
@@ -46,11 +51,13 @@ namespace xIdentityModels.Models {
string refreshToken,
long expiresAt,
IEnumerable<Claim> claims
) {
)
{
//
// refreshToken.IsNullOrEmpty ()
if (claims.IsNull() ||
accessToken.IsNullOrEmpty ()) {
accessToken.IsNullOrEmpty())
{
XException.InvalidArgs.Throw();
}
@@ -61,7 +68,9 @@ namespace xIdentityModels.Models {
ExpiresAt = expiresAt;
//
if (!claims.IsNull ()) {
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 ?? "";
@@ -70,22 +79,48 @@ namespace xIdentityModels.Models {
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 ()) {
if (genderStr.IsNullOrEmpty())
{
Gender = XGender.Male;
} else {
}
else
{
Gender = genderStr.GetValue<XGender>();
}
//
// Handle IsBanned ...
var isBannedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsBanned).Value ?? null;
if (isBannedStr.IsNullOrEmpty ()) {
if (isBannedStr.IsNullOrEmpty())
{
IsBanned = false;
} else {
}
else
{
//
var isBanned = false;
Boolean.TryParse(isBannedStr, out isBanned);
@@ -97,9 +132,12 @@ namespace xIdentityModels.Models {
//
// Handle IsEnabled ...
var isEnabledStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsEnabled).Value ?? null;
if (isEnabledStr.IsNullOrEmpty ()) {
if (isEnabledStr.IsNullOrEmpty())
{
IsEnabled = false;
} else {
}
else
{
//
var isEnabled = false;
Boolean.TryParse(isEnabledStr, out isEnabled);
@@ -111,9 +149,12 @@ namespace xIdentityModels.Models {
//
// Handle Email Confirmed ...
var emailConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.EmailVerified).Value ?? null;
if (emailConfirmedStr.IsNullOrEmpty ()) {
if (emailConfirmedStr.IsNullOrEmpty())
{
EmailConfirmed = false;
} else {
}
else
{
//
var emailConfirmed = false;
Boolean.TryParse(emailConfirmedStr, out emailConfirmed);
@@ -125,9 +166,12 @@ namespace xIdentityModels.Models {
//
// Handle PhoneNumber Confirmed ...
var phoneNumberConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.PhoneNumberVerified).Value ?? null;
if (phoneNumberConfirmedStr.IsNullOrEmpty ()) {
if (phoneNumberConfirmedStr.IsNullOrEmpty())
{
PhoneNumberConfirmed = false;
} else {
}
else
{
//
var phoneNumberConfirmed = false;
Boolean.TryParse(phoneNumberConfirmedStr, out phoneNumberConfirmed);
@@ -139,9 +183,12 @@ namespace xIdentityModels.Models {
//
// Handle ExpiredOn ...
var expiredOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.ExpiredOn).Value ?? null;
if (expiredOnStr.IsNullOrEmpty ()) {
if (expiredOnStr.IsNullOrEmpty())
{
ExpiredOn = null;
} else {
}
else
{
//
long expiredOn = 0;
long.TryParse(expiredOnStr, out expiredOn);
@@ -153,9 +200,12 @@ namespace xIdentityModels.Models {
//
// Handle AuthenticatedOn ...
var authenticatedOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.AuthenticatedOn).Value ?? null;
if (authenticatedOnStr.IsNullOrEmpty ()) {
if (authenticatedOnStr.IsNullOrEmpty())
{
AuthenticatedOn = null;
} else {
}
else
{
//
long authenticatedOn = 0;
long.TryParse(authenticatedOnStr, out authenticatedOn);
@@ -167,9 +217,12 @@ namespace xIdentityModels.Models {
//
// Handle BrithDate ...
var brithDateStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.BrithDate)?.Value ?? "";
if (brithDateStr.IsNullOrEmpty ()) {
if (brithDateStr.IsNullOrEmpty())
{
// BrithDate = null;
} else {
}
else
{
//
DateTime bDate;
DateTime.TryParse(brithDateStr, out bDate);
@@ -179,6 +232,7 @@ namespace xIdentityModels.Models {
}
//
// Collections ...
Issuers = claims.Where(c => c.Type == XCustomClaims.Issuer)?
.Select(c => c.Value) ?? new HashSet<string>();
Audiences = claims.Where(c => c.Type == XCustomClaims.Audience)?
+20 -3
View File
@@ -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>
@@ -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
//
@@ -82,12 +99,12 @@ namespace xIdentityModels {
/// <returns>a Collection of all assigned Devices to User</returns>
[InverseProperty("User")]
public virtual ICollection<XDevice> Devices { get; set; } = new HashSet<XDevice>();
[InverseProperty ("User")]
/// <summary>
/// User's Avatars
/// </summary>
/// <typeparam name="XProfileImage"><see>XProfileImage</see></typeparam>
/// <returns>a Collection of all assigned Avatars to User</returns>
[InverseProperty("User")]
public virtual ICollection<XProfileImage> Avatars { get; set; } = new HashSet<XProfileImage>();
/// <summary>
/// User's Followers