Class UserClaimsPrincipalFactory<TUser, TRole>
Provides methods to create a claims principal for a given user.
Inherited Members
Namespace: IRM.AspNetCore.Identity
Assembly: IRM.AspNetCore.Identity.dll
Syntax
public class UserClaimsPrincipalFactory<TUser, TRole> : IUserClaimsPrincipalFactory<TUser> where TUser : class, IUser where TRole : class, IRole, new()
Type Parameters
TUser
The type used to represent a user. |
TRole
The type used to represent a role. |
Constructors
UserClaimsPrincipalFactory(UserManager<TUser>, RoleManager<TRole>, IOptions<IdentityOptions>, IUserPictureProvider)
Initializes a new instance of the UserClaimsPrincipalFactory<TUser, TRole> class.
Declaration
public UserClaimsPrincipalFactory(UserManager<TUser> userManager, RoleManager<TRole> roleManager, IOptions<IdentityOptions> optionsAccessor, IUserPictureProvider pictureProvider = null)
Parameters
UserManager<TUser>
userManager
The UserManager<TUser> to retrieve user information from. |
Microsoft.AspNetCore.Identity.RoleManager<TRole>
roleManager
The Microsoft.AspNetCore.Identity.RoleManager<TRole> to retrieve a user's roles from. |
Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Identity.IdentityOptions>
optionsAccessor
The configured Microsoft.AspNetCore.Identity.IdentityOptions. |
IUserPictureProvider
pictureProvider
The configured IUserPictureProvider used to create the picture claim (if any). |
Methods
CreateAsync(TUser)
Creates a System.Security.Claims.ClaimsPrincipal from an user asynchronously.
Declaration
public virtual async Task<ClaimsPrincipal> CreateAsync(TUser user)
Parameters
TUser
user
The user to create a System.Security.Claims.ClaimsPrincipal from. |
Returns
System.Threading.Tasks.Task<System.Security.Claims.ClaimsPrincipal>
The System.Threading.Tasks.Task that represents the asynchronous creation operation, containing the created System.Security.Claims.ClaimsPrincipal. |
Implements
GetPictureClaimValue(TUser)
Gets a picture URL for a user.
Declaration
protected virtual async Task<string> GetPictureClaimValue(TUser user)
Parameters
TUser
user
The user to create a picture url for. |
Returns
System.Threading.Tasks.Task<String>
The url to a user picture, or null if the user doesn't have a picture. |
RemoveDuplicates(ClaimsIdentity)
Declaration
protected virtual void RemoveDuplicates(ClaimsIdentity identity)
Parameters
System.Security.Claims.ClaimsIdentity
identity
|