Compare commits
10
Commits
f8e07ed23b
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccae6137fb | ||
|
|
1b32632a83 | ||
|
|
f296f0eb7a | ||
|
|
ab714c9894 | ||
|
|
7799188db9 | ||
|
|
cb64a8dac9 | ||
|
|
8182f98b3c | ||
|
|
d9b33de198 | ||
|
|
6a2618a3c4 | ||
|
|
23e68de1ef |
@@ -1,3 +1,3 @@
|
|||||||
namespace xIdentityModels.DI {
|
namespace xIdentityModels.DI {
|
||||||
public static class XDIHelperExtension { }
|
public static partial class XDIHelperExtension { }
|
||||||
}
|
}
|
||||||
@@ -84,6 +84,24 @@ namespace xIdentityModels.Dtos {
|
|||||||
NullValueHandling = NullValueHandling.Ignore)]
|
NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public XGender Gender { get; set; }
|
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 (
|
[JsonProperty (
|
||||||
"friendshipInfo",
|
"friendshipInfo",
|
||||||
Required = Required.Default,
|
Required = Required.Default,
|
||||||
|
|||||||
@@ -1,3 +1,199 @@
|
|||||||
namespace xIdentityModels.Extensions {
|
using System.Collections.Generic;
|
||||||
public static class xIdentityModelsExtensions { }
|
using System.Linq;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xIdentityModels.Configurations;
|
||||||
|
using xIdentityModels.Constants;
|
||||||
|
using xIdentityModels.Dtos;
|
||||||
|
using xIdentityModels.Models;
|
||||||
|
|
||||||
|
namespace xIdentityModels.Extensions
|
||||||
|
{
|
||||||
|
public static class xIdentityModelsExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a User Entity to Profile Dto ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="isAdmin"></param>
|
||||||
|
/// <param name="isSameUser"></param>
|
||||||
|
/// <param name="roles"></param>
|
||||||
|
/// <param name="friendship"></param>
|
||||||
|
/// <param name="profileConfig"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static XUserProfileDto ToXProfileDto(
|
||||||
|
this XUser source,
|
||||||
|
bool isAdmin = false,
|
||||||
|
bool isSameUser = false,
|
||||||
|
IEnumerable<string> roles = null,
|
||||||
|
XFriendshipInfoDto friendship = null,
|
||||||
|
XIdentityProfile profileConfig = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XUserProfileDto result = null;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (roles == null)
|
||||||
|
{
|
||||||
|
roles = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Dto ...
|
||||||
|
if (!source.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = new XUserProfileDto
|
||||||
|
{
|
||||||
|
Bio = source.Bio,
|
||||||
|
UserId = source.Id,
|
||||||
|
Email = source.Email,
|
||||||
|
Roles = roles.ToList(),
|
||||||
|
Avatar = source.Avatar,
|
||||||
|
IsEnable = source.IsEnable,
|
||||||
|
IsBanned = source.IsBanned,
|
||||||
|
UserName = source.UserName,
|
||||||
|
LastName = source.LastName,
|
||||||
|
FriendshipInfo = friendship,
|
||||||
|
FirstName = source.FirstName,
|
||||||
|
LastLogin = source.LastLogin,
|
||||||
|
CoverImage = source.CoverImage,
|
||||||
|
PhoneNumber = source.PhoneNumber,
|
||||||
|
DateOfBirth = source.DateOfBirth,
|
||||||
|
CreationDate = source.CreationDate,
|
||||||
|
OpenToSearch = source.OpenToSearch,
|
||||||
|
Gender = (XGender)(int)source.Gender,
|
||||||
|
EmailConfirmed = source.EmailConfirmed,
|
||||||
|
PhoneNumberConfirmed = source.PhoneNumberConfirmed,
|
||||||
|
Avatars = source.Avatars.Select(pfi =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return new XProfileImageDto
|
||||||
|
{
|
||||||
|
Id = pfi.Id,
|
||||||
|
Name = pfi.Name,
|
||||||
|
Path = pfi.Path,
|
||||||
|
Thumb = pfi.Thumb,
|
||||||
|
ThumbPath = pfi.ThumbPath,
|
||||||
|
CreationDate = pfi.CreationDate
|
||||||
|
};
|
||||||
|
}).ToList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Profiling Configuration ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPassed = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Friendship ...
|
||||||
|
isPassed = !isSameUser;
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.FriendshipInfo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Email Info ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsEmail);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.Email = string.Empty;
|
||||||
|
result.EmailConfirmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle PhoneNumber Info ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsPhoneNumber);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
source.PhoneNumber = string.Empty;
|
||||||
|
source.PhoneNumberConfirmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Last Login ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsLastLogin);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.LastLogin = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Date Of Birth ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsDateOfBirth);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.DateOfBirth = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Creation Date ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsCreationDate);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.CreationDate = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Roles ...
|
||||||
|
isPassed = isAdmin || isSameUser || (!profileConfig.IsNullOrDefault() && profileConfig.ContainsRoles);
|
||||||
|
if (!isPassed)
|
||||||
|
{
|
||||||
|
result.Roles = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Specified User Has Access to Provided Roles ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="roles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool HasAccess(
|
||||||
|
this XUserClaimsInfoDto source,
|
||||||
|
string[] roles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result =
|
||||||
|
!source.IsNullOrDefault() &&
|
||||||
|
source.Roles
|
||||||
|
.Any(r => roles
|
||||||
|
.Any(ar => r.ToNormalString()
|
||||||
|
.Contains(ar.ToNormalString())));
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Specified User Contains Specified UserSelectByParam or not ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="userSelectByParam"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ContainsUserSelectByParam(
|
||||||
|
this XUser source,
|
||||||
|
string userSelectByParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result =
|
||||||
|
!source.IsNull() &&
|
||||||
|
!userSelectByParam.IsNullOrEmpty() &&
|
||||||
|
(source.Id == userSelectByParam ||
|
||||||
|
source.Email.ToNormalString() == userSelectByParam.ToNormalString() ||
|
||||||
|
source.UserName.ToNormalString() == userSelectByParam.ToNormalString() ||
|
||||||
|
source.PhoneNumber.ToNormalString() == userSelectByParam.ToNormalString());
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,5 +18,8 @@ namespace xIdentityModels.Models {
|
|||||||
public ICollection<string> Roles { get; set; } = new HashSet<string> ();
|
public ICollection<string> Roles { get; set; } = new HashSet<string> ();
|
||||||
public bool? IsEnable { get; set; }
|
public bool? IsEnable { get; set; }
|
||||||
public bool? IsBanned { get; set; }
|
public bool? IsBanned { get; set; }
|
||||||
|
public string Bio { get; set; }
|
||||||
|
public string CoverImage { get; set; }
|
||||||
|
public bool OpenToSearch { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+118
-64
@@ -9,8 +9,10 @@ using xExceptions.Constants;
|
|||||||
using xIdentityModels.Constants;
|
using xIdentityModels.Constants;
|
||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
|
|
||||||
namespace xIdentityModels.Models {
|
namespace xIdentityModels.Models
|
||||||
public class XUserClaimsInfoDto : XBaseDto {
|
{
|
||||||
|
public class XUserClaimsInfoDto : XBaseDto
|
||||||
|
{
|
||||||
//
|
//
|
||||||
#region Properties ...
|
#region Properties ...
|
||||||
public string AccessToken { get; }
|
public string AccessToken { get; }
|
||||||
@@ -28,30 +30,35 @@ namespace xIdentityModels.Models {
|
|||||||
public bool IsEnabled { get; }
|
public bool IsEnabled { get; }
|
||||||
public bool EmailConfirmed { get; }
|
public bool EmailConfirmed { get; }
|
||||||
public bool PhoneNumberConfirmed { 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? ExpiredOn { get; }
|
||||||
public long? AuthenticatedOn { get; }
|
public long? AuthenticatedOn { get; }
|
||||||
public DateTime? BrithDate { get; }
|
public DateTime? BrithDate { get; }
|
||||||
public IEnumerable<string> Issuers { get; } = new HashSet<string> ();
|
public IEnumerable<string> Issuers { get; } = new HashSet<string>();
|
||||||
public IEnumerable<string> Audiences { get; } = new HashSet<string> ();
|
public IEnumerable<string> Audiences { get; } = new HashSet<string>();
|
||||||
public IEnumerable<string> ClientIds { get; } = new HashSet<string> ();
|
public IEnumerable<string> ClientIds { get; } = new HashSet<string>();
|
||||||
public IEnumerable<string> Scopes { get; } = new HashSet<string> ();
|
public IEnumerable<string> Scopes { get; } = new HashSet<string>();
|
||||||
public IEnumerable<string> Roles { get; } = new HashSet<string> ();
|
public IEnumerable<string> Roles { get; } = new HashSet<string>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
public XUserClaimsInfoDto () { }
|
public XUserClaimsInfoDto() { }
|
||||||
|
|
||||||
public XUserClaimsInfoDto (
|
public XUserClaimsInfoDto(
|
||||||
string accessToken,
|
string accessToken,
|
||||||
string refreshToken,
|
string refreshToken,
|
||||||
long expiresAt,
|
long expiresAt,
|
||||||
IEnumerable<Claim> claims
|
IEnumerable<Claim> claims
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// refreshToken.IsNullOrEmpty ()
|
// refreshToken.IsNullOrEmpty ()
|
||||||
if (claims.IsNull () ||
|
if (claims.IsNull() ||
|
||||||
accessToken.IsNullOrEmpty ()) {
|
accessToken.IsNullOrEmpty())
|
||||||
XException.InvalidArgs.Throw ();
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -61,34 +68,62 @@ namespace xIdentityModels.Models {
|
|||||||
ExpiresAt = expiresAt;
|
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 ?? "";
|
UserId = claims.FirstOrDefault(c => c.Type == XCustomClaims.UserId)?.Value ?? "";
|
||||||
LastName = claims.FirstOrDefault (c => c.Type == XCustomClaims.LastName)?.Value ?? "";
|
UserName = claims.FirstOrDefault(c => c.Type == XCustomClaims.UserName)?.Value ?? "";
|
||||||
Picture = claims.FirstOrDefault (c => c.Type == XCustomClaims.Picture)?.Value ?? "";
|
FirstName = claims.FirstOrDefault(c => c.Type == XCustomClaims.FirstName)?.Value ?? "";
|
||||||
Email = claims.FirstOrDefault (c => c.Type == XCustomClaims.Email)?.Value ?? null;
|
LastName = claims.FirstOrDefault(c => c.Type == XCustomClaims.LastName)?.Value ?? "";
|
||||||
PhoneNumber = claims.FirstOrDefault (c => c.Type == XCustomClaims.PhoneNumber)?.Value ?? null;
|
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 ...
|
// Handle Gender ...
|
||||||
var genders = ObjectHelper.ToEnumerableKeys<XGender> ();
|
var genders = ObjectHelper.ToEnumerableKeys<XGender>();
|
||||||
var genderStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.Gender).Value ?? null;
|
var genderStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.Gender).Value ?? null;
|
||||||
if (genderStr.IsNullOrEmpty ()) {
|
if (genderStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
Gender = XGender.Male;
|
Gender = XGender.Male;
|
||||||
} else {
|
}
|
||||||
Gender = genderStr.GetValue<XGender> ();
|
else
|
||||||
|
{
|
||||||
|
Gender = genderStr.GetValue<XGender>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle IsBanned ...
|
// Handle IsBanned ...
|
||||||
var isBannedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.IsBanned).Value ?? null;
|
var isBannedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsBanned).Value ?? null;
|
||||||
if (isBannedStr.IsNullOrEmpty ()) {
|
if (isBannedStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
IsBanned = false;
|
IsBanned = false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
var isBanned = false;
|
var isBanned = false;
|
||||||
Boolean.TryParse (isBannedStr, out isBanned);
|
Boolean.TryParse(isBannedStr, out isBanned);
|
||||||
|
|
||||||
//
|
//
|
||||||
IsBanned = isBanned;
|
IsBanned = isBanned;
|
||||||
@@ -96,13 +131,16 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle IsEnabled ...
|
// Handle IsEnabled ...
|
||||||
var isEnabledStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.IsEnabled).Value ?? null;
|
var isEnabledStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.IsEnabled).Value ?? null;
|
||||||
if (isEnabledStr.IsNullOrEmpty ()) {
|
if (isEnabledStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
IsEnabled = false;
|
IsEnabled = false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
var isEnabled = false;
|
var isEnabled = false;
|
||||||
Boolean.TryParse (isEnabledStr, out isEnabled);
|
Boolean.TryParse(isEnabledStr, out isEnabled);
|
||||||
|
|
||||||
//
|
//
|
||||||
IsEnabled = isEnabled;
|
IsEnabled = isEnabled;
|
||||||
@@ -110,13 +148,16 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle Email Confirmed ...
|
// Handle Email Confirmed ...
|
||||||
var emailConfirmedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.EmailVerified).Value ?? null;
|
var emailConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.EmailVerified).Value ?? null;
|
||||||
if (emailConfirmedStr.IsNullOrEmpty ()) {
|
if (emailConfirmedStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
EmailConfirmed = false;
|
EmailConfirmed = false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
var emailConfirmed = false;
|
var emailConfirmed = false;
|
||||||
Boolean.TryParse (emailConfirmedStr, out emailConfirmed);
|
Boolean.TryParse(emailConfirmedStr, out emailConfirmed);
|
||||||
|
|
||||||
//
|
//
|
||||||
EmailConfirmed = emailConfirmed;
|
EmailConfirmed = emailConfirmed;
|
||||||
@@ -124,13 +165,16 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle PhoneNumber Confirmed ...
|
// Handle PhoneNumber Confirmed ...
|
||||||
var phoneNumberConfirmedStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.PhoneNumberVerified).Value ?? null;
|
var phoneNumberConfirmedStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.PhoneNumberVerified).Value ?? null;
|
||||||
if (phoneNumberConfirmedStr.IsNullOrEmpty ()) {
|
if (phoneNumberConfirmedStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
PhoneNumberConfirmed = false;
|
PhoneNumberConfirmed = false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
var phoneNumberConfirmed = false;
|
var phoneNumberConfirmed = false;
|
||||||
Boolean.TryParse (phoneNumberConfirmedStr, out phoneNumberConfirmed);
|
Boolean.TryParse(phoneNumberConfirmedStr, out phoneNumberConfirmed);
|
||||||
|
|
||||||
//
|
//
|
||||||
PhoneNumberConfirmed = phoneNumberConfirmed;
|
PhoneNumberConfirmed = phoneNumberConfirmed;
|
||||||
@@ -138,13 +182,16 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle ExpiredOn ...
|
// Handle ExpiredOn ...
|
||||||
var expiredOnStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.ExpiredOn).Value ?? null;
|
var expiredOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.ExpiredOn).Value ?? null;
|
||||||
if (expiredOnStr.IsNullOrEmpty ()) {
|
if (expiredOnStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
ExpiredOn = null;
|
ExpiredOn = null;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
long expiredOn = 0;
|
long expiredOn = 0;
|
||||||
long.TryParse (expiredOnStr, out expiredOn);
|
long.TryParse(expiredOnStr, out expiredOn);
|
||||||
|
|
||||||
//
|
//
|
||||||
ExpiredOn = expiredOn;
|
ExpiredOn = expiredOn;
|
||||||
@@ -152,13 +199,16 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle AuthenticatedOn ...
|
// Handle AuthenticatedOn ...
|
||||||
var authenticatedOnStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.AuthenticatedOn).Value ?? null;
|
var authenticatedOnStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.AuthenticatedOn).Value ?? null;
|
||||||
if (authenticatedOnStr.IsNullOrEmpty ()) {
|
if (authenticatedOnStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
AuthenticatedOn = null;
|
AuthenticatedOn = null;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
long authenticatedOn = 0;
|
long authenticatedOn = 0;
|
||||||
long.TryParse (authenticatedOnStr, out authenticatedOn);
|
long.TryParse(authenticatedOnStr, out authenticatedOn);
|
||||||
|
|
||||||
//
|
//
|
||||||
AuthenticatedOn = authenticatedOn;
|
AuthenticatedOn = authenticatedOn;
|
||||||
@@ -166,29 +216,33 @@ namespace xIdentityModels.Models {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Handle BrithDate ...
|
// Handle BrithDate ...
|
||||||
var brithDateStr = claims.FirstOrDefault (c => c.Type == XCustomClaims.BrithDate)?.Value ?? "";
|
var brithDateStr = claims.FirstOrDefault(c => c.Type == XCustomClaims.BrithDate)?.Value ?? "";
|
||||||
if (brithDateStr.IsNullOrEmpty ()) {
|
if (brithDateStr.IsNullOrEmpty())
|
||||||
|
{
|
||||||
// BrithDate = null;
|
// BrithDate = null;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
DateTime bDate;
|
DateTime bDate;
|
||||||
DateTime.TryParse (brithDateStr, out bDate);
|
DateTime.TryParse(brithDateStr, out bDate);
|
||||||
|
|
||||||
//
|
//
|
||||||
BrithDate = bDate;
|
BrithDate = bDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
Issuers = claims.Where (c => c.Type == XCustomClaims.Issuer) ?
|
// Collections ...
|
||||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
Issuers = claims.Where(c => c.Type == XCustomClaims.Issuer)?
|
||||||
Audiences = claims.Where (c => c.Type == XCustomClaims.Audience) ?
|
.Select(c => c.Value) ?? new HashSet<string>();
|
||||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
Audiences = claims.Where(c => c.Type == XCustomClaims.Audience)?
|
||||||
ClientIds = claims.Where (c => c.Type == XCustomClaims.ClientId) ?
|
.Select(c => c.Value) ?? new HashSet<string>();
|
||||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
ClientIds = claims.Where(c => c.Type == XCustomClaims.ClientId)?
|
||||||
Scopes = claims.Where (c => c.Type == XCustomClaims.Scope) ?
|
.Select(c => c.Value) ?? new HashSet<string>();
|
||||||
.Select (c => c.Value) ?? new HashSet<string> ();
|
Scopes = claims.Where(c => c.Type == XCustomClaims.Scope)?
|
||||||
Roles = claims.Where (c => c.Type == XCustomClaims.Role) ?
|
.Select(c => c.Value) ?? new HashSet<string>();
|
||||||
.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.Constants;
|
||||||
using xIdentityModels.Navigations;
|
using xIdentityModels.Navigations;
|
||||||
|
|
||||||
namespace xIdentityModels {
|
namespace xIdentityModels
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// represnt a User of System
|
/// represnt a User of System
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class XUser : IdentityUser {
|
public partial class XUser : IdentityUser
|
||||||
|
{
|
||||||
//
|
//
|
||||||
#region Properties ...
|
#region Properties ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -18,14 +20,14 @@ namespace xIdentityModels {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>user's FirstName</value>
|
/// <value>user's FirstName</value>
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength (50)]
|
[StringLength(50)]
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// LastName
|
/// LastName
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>user's LastName</value>
|
/// <value>user's LastName</value>
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength (100)]
|
[StringLength(100)]
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User is Enabled or not
|
/// User is Enabled or not
|
||||||
@@ -71,6 +73,21 @@ namespace xIdentityModels {
|
|||||||
/// <value>user's Gender</value>
|
/// <value>user's Gender</value>
|
||||||
[Required]
|
[Required]
|
||||||
public XGender Gender { get; set; }
|
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
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -80,34 +97,34 @@ namespace xIdentityModels {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="XDevice"><see>XDevice</see></typeparam>
|
/// <typeparam name="XDevice"><see>XDevice</see></typeparam>
|
||||||
/// <returns>a Collection of all assigned Devices to User</returns>
|
/// <returns>a Collection of all assigned Devices to User</returns>
|
||||||
[InverseProperty ("User")]
|
[InverseProperty("User")]
|
||||||
public virtual ICollection<XDevice> Devices { get; set; } = new HashSet<XDevice> ();
|
public virtual ICollection<XDevice> Devices { get; set; } = new HashSet<XDevice>();
|
||||||
[InverseProperty ("User")]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User's Avatars
|
/// User's Avatars
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="XProfileImage"><see>XProfileImage</see></typeparam>
|
/// <typeparam name="XProfileImage"><see>XProfileImage</see></typeparam>
|
||||||
/// <returns>a Collection of all assigned Avatars to User</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// User's Followers
|
/// User's Followers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="XFriendshipFollower"><see>XFriendshipFollower</see></typeparam>
|
/// <typeparam name="XFriendshipFollower"><see>XFriendshipFollower</see></typeparam>
|
||||||
/// <returns>a Collection of all User's Followers</returns>
|
/// <returns>a Collection of all User's Followers</returns>
|
||||||
[InverseProperty ("User")]
|
[InverseProperty("User")]
|
||||||
public virtual ICollection<XFriendshipFollower> Followers { get; set; } = new HashSet<XFriendshipFollower> ();
|
public virtual ICollection<XFriendshipFollower> Followers { get; set; } = new HashSet<XFriendshipFollower>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User's Followings
|
/// User's Followings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="XFriendshipFollowing"><see>XFriendshipFollowing</see></typeparam>
|
/// <typeparam name="XFriendshipFollowing"><see>XFriendshipFollowing</see></typeparam>
|
||||||
/// <returns>a Collection of all User's Followings</returns>
|
/// <returns>a Collection of all User's Followings</returns>
|
||||||
[InverseProperty ("User")]
|
[InverseProperty("User")]
|
||||||
public virtual ICollection<XFriendshipFollowing> Followings { get; set; } = new HashSet<XFriendshipFollowing> ();
|
public virtual ICollection<XFriendshipFollowing> Followings { get; set; } = new HashSet<XFriendshipFollowing>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User's Roles
|
/// User's Roles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a Collection of all User's Roles in System</returns>
|
/// <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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
|
<!-- <add key="megan" value="https://hub.megan.ir/nuget/index.json" /> -->
|
||||||
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" />
|
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" disableTLSCertificateValidation="true" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
</configuration>
|
</configuration>
|
||||||
+18
-5
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
<!-- Runtime Definition -->
|
<!-- Runtime Definition -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
|
||||||
<PackageId>xDashboard.xIdentityModels</PackageId>
|
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
|
<LangVersion>12.0</LangVersion>
|
||||||
<Authors>Hadi Khazaee Asl</Authors>
|
<Authors>Hadi Khazaee Asl</Authors>
|
||||||
<Company>SaherElm IT Center</Company>
|
<Company>SaherElm IT Center</Company>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<PackageId>xDashboard.xIdentityModels</PackageId>
|
||||||
|
|
||||||
<Description>
|
<Description>
|
||||||
it is a Part of xDashboard on SaherElm IT Center which provides all required identity models
|
it is a Part of xDashboard on SaherElm IT Center which provides all required identity models
|
||||||
</Description>
|
</Description>
|
||||||
@@ -17,20 +19,31 @@
|
|||||||
|
|
||||||
<!-- Icon Handling -->
|
<!-- Icon Handling -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
<None Include="../../Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
||||||
|
PackagePath="\icon.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Local Modules -->
|
<!-- Local Modules -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- <PackageReference Include="xDashboard.xModels" Version="1.0.0" /> -->
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Local Dependencies -->
|
||||||
|
<ItemGroup>
|
||||||
<ProjectReference Include="../xModels/xModels.csproj" />
|
<ProjectReference Include="../xModels/xModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Nuget Package Dependencies -->
|
<!-- Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- For XML Documentation Support -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user