Class ExtendedUserManager<TUser>
Provides the APIs for managing user in a persistence store.
Inherited Members
Namespace: IRM.AspNetCore.Identity
Assembly: IRM.AspNetCore.Identity.dll
Syntax
public class ExtendedUserManager<TUser> : UserManager<TUser>, IDisposable where TUser : class, IUser
Type Parameters
TUser
The type encapsulating a user. |
Constructors
ExtendedUserManager(IUserStore<TUser>, IOptions<ExtendedIdentityOptions>, IPasswordHasher<TUser>, IEnumerable<IUserValidator<TUser>>, IEnumerable<IPasswordValidator<TUser>>, ILookupNormalizer, ExtendedIdentityErrorDescriber, IServiceProvider, ILogger<ExtendedUserManager<TUser>>)
Constructs a new instance of ExtendedUserManager<TUser>.
Declaration
public ExtendedUserManager(IUserStore<TUser> store, IOptions<ExtendedIdentityOptions> optionsAccessor, IPasswordHasher<TUser> passwordHasher, IEnumerable<IUserValidator<TUser>> userValidators, IEnumerable<IPasswordValidator<TUser>> passwordValidators, ILookupNormalizer keyNormalizer, ExtendedIdentityErrorDescriber errorDescriber, IServiceProvider services, ILogger<ExtendedUserManager<TUser>> logger)
Parameters
IUserStore<TUser>
store
The persistence store the manager will operate over. |
Microsoft.Extensions.Options.IOptions<ExtendedIdentityOptions>
optionsAccessor
The accessor used to access the ExtendedIdentityOptions. |
Microsoft.AspNetCore.Identity.IPasswordHasher<TUser>
passwordHasher
The password hashing implementation to use when saving passwords. |
IEnumerable<IUserValidator<TUser>>
userValidators
A collection of IUserValidator<TUser> to validate users against. |
IEnumerable<Microsoft.AspNetCore.Identity.IPasswordValidator<TUser>>
passwordValidators
A collection of Microsoft.AspNetCore.Identity.IPasswordValidator<TUser> to validate passwords against. |
Microsoft.AspNetCore.Identity.ILookupNormalizer
keyNormalizer
The Microsoft.AspNetCore.Identity.ILookupNormalizer to use when generating index keys for users. |
ExtendedIdentityErrorDescriber
errorDescriber
The ExtendedIdentityErrorDescriber used to provider error messages. |
System.IServiceProvider
services
The System.IServiceProvider used to resolve services. |
Microsoft.Extensions.Logging.ILogger<ExtendedUserManager<TUser>>
logger
The logger used to log messages, warnings and errors. |
Properties
Context
Gets the Microsoft.AspNetCore.Http.HttpContext.
Declaration
protected HttpContext Context { get; }
Property Value
Microsoft.AspNetCore.Http.HttpContext
|
Options
The ExtendedIdentityOptions used to configure Identity.
Declaration
public ExtendedIdentityOptions Options { get; set; }
Property Value
ExtendedIdentityOptions
|
Store
Gets the persistence store the manager operates over.
Declaration
protected IUserStore<TUser> Store { get; }
Property Value
IUserStore<TUser>
The persistence store the manager operates over. |
Methods
AccessFailedAsync(TUser)
Declaration
public override Task<IdentityResult> AccessFailedAsync(TUser user)
Parameters
TUser
user
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
AddClaimsAsync(TUser, IEnumerable<Claim>)
Declaration
public override async Task<IdentityResult> AddClaimsAsync(TUser user, IEnumerable<Claim> claims)
Parameters
TUser
user
|
IEnumerable<System.Security.Claims.Claim>
claims
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
AddLoginAsync(TUser, UserLoginInfo)
Adds an external Microsoft.AspNetCore.Identity.UserLoginInfo to the specified user
.
Declaration
public override async Task<IdentityResult> AddLoginAsync(TUser user, UserLoginInfo login)
Parameters
TUser
user
The user to add the login to. |
Microsoft.AspNetCore.Identity.UserLoginInfo
login
The external Microsoft.AspNetCore.Identity.UserLoginInfo to add to the specified |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
Overrides
AddPermissionAsync(TUser, String)
Adds the specified permission
to the user.
Declaration
public virtual async Task<IdentityResult> AddPermissionAsync(TUser user, string permission)
Parameters
TUser
user
The user to add the permission to. |
String
permission
The Permission to add. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the add. |
AddRequiredInformationAsync(TUser, String, String)
Adds an e-mail address and/or a phone number to a user.
Declaration
public virtual async Task<IdentityResult> AddRequiredInformationAsync(TUser user, string email, string phoneNumber)
Parameters
TUser
user
The |
String
email
The email address to be added to the user. |
String
phoneNumber
The phone number to be added to the user. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the operation. |
AssociateSignInAsync(TUser, UserLoginInfo, String)
Associates an invited user with a local user account.
Declaration
public virtual async Task<IdentityResult> AssociateSignInAsync(TUser user, UserLoginInfo login, string token)
Parameters
TUser
user
The user to associate. |
Microsoft.AspNetCore.Identity.UserLoginInfo
login
The external Microsoft.AspNetCore.Identity.UserLoginInfo to associate with the specified |
String
token
The invitation token to validate. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
AssociateSignInAsync(TUser, String, String)
Associates an invited user with a local user account.
Declaration
public virtual async Task<IdentityResult> AssociateSignInAsync(TUser user, string password, string token)
Parameters
TUser
user
The user to associate. |
String
password
The password for the user to hash and store. |
String
token
The invitation token to validate. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
ChangePasswordAsync(TUser, String, String)
Declaration
public override async Task<IdentityResult> ChangePasswordAsync(TUser user, string currentPassword, string newPassword)
Parameters
TUser
user
|
String
currentPassword
|
String
newPassword
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
CreateAsync(TUser)
Declaration
public override Task<IdentityResult> CreateAsync(TUser user)
Parameters
TUser
user
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
CreateAsync(TUser, Boolean, String)
Creates the specified user in the backing store with no password, as an asynchronous operation.
Declaration
public async Task<IdentityResult> CreateAsync(TUser user, bool sendInvitation = false, string additionalInvitationParameters = null)
Parameters
TUser
user
The user to create. |
Boolean
sendInvitation
Indicates if an invitation should be sent to the user. |
String
additionalInvitationParameters
Additional parameters to add in the link of an invitation. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The IdentityResult of the operation. |
DeleteAsync(TUser)
Declaration
public override Task<IdentityResult> DeleteAsync(TUser user)
Parameters
TUser
user
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
DeleteAsync(Guid)
Deletes the user with the specified userId
from the backing store.
Declaration
public virtual async Task<IdentityResult> DeleteAsync(Guid userId)
Parameters
System.Guid
userId
The id of the user to delete. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
ExecuteClaimFiltersAsync(TUser, ClaimFilterContext<TUser>)
Executes all
Declaration
public virtual async Task ExecuteClaimFiltersAsync(TUser user, ClaimFilterContext<TUser> context)
Parameters
TUser
user
The user to update. |
ClaimFilterContext<TUser> context |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the ClaimFilterContext<TUser>. |
ExecuteClaimFiltersAsync(ClaimFilterContext<TUser>)
Executes all
Declaration
public virtual async Task ExecuteClaimFiltersAsync(ClaimFilterContext<TUser> context)
Parameters
ClaimFilterContext<TUser> context |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the ClaimFilterContext<TUser>. |
FindUsersByEmailAsync(String)
Finds and returns a list of user, if any, who has the specified email address, without filtering on a tenant.
Declaration
public virtual async Task<List<TUser>> FindUsersByEmailAsync(string email)
Parameters
String
email
The email address to search for. |
Returns
System.Threading.Tasks.Task<List<TUser>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified |
FindUsersByLoginAsync(String, String)
Finds and returns a list of users associated with the specified external login provider and login provider key, without filtering on a tenant.
Declaration
public virtual async Task<List<TUser>> FindUsersByLoginAsync(string loginProvider, string providerKey)
Parameters
String
loginProvider
The login provider who provided the |
String
providerKey
The key provided by the |
Returns
System.Threading.Tasks.Task<List<TUser>>
The System.Threading.Tasks.Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key. |
FindUsersByNameAsync(String)
Finds and returns a list of user, if any, who has the specified user name, without filtering on a tenant.
Declaration
public virtual async Task<List<TUser>> FindUsersByNameAsync(string userName)
Parameters
String
userName
The user name to search for. |
Returns
System.Threading.Tasks.Task<List<TUser>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified |
GenerateInvitationTokenAsync(TUser)
Generates an email invitation token for the specified user.
Declaration
public virtual async Task<string> GenerateInvitationTokenAsync(TUser user)
Parameters
TUser
user
The user to generate an email invitation token for. |
Returns
System.Threading.Tasks.Task<String>
The System.Threading.Tasks.Task that represents the asynchronous operation, an email invitation token. |
GenerateOneTimePasswordAsync(TUser)
Generates a phone token for the specified user.
Declaration
public virtual async Task<string> GenerateOneTimePasswordAsync(TUser user)
Parameters
TUser
user
The user to generate a phone token for. |
Returns
System.Threading.Tasks.Task<String>
The System.Threading.Tasks.Task that represents the asynchronous operation, a phone token. |
GetAllSystemUsersAsync()
Gets all users that represents systems.
Declaration
public virtual Task<List<TUser>> GetAllSystemUsersAsync()
Returns
System.Threading.Tasks.Task<List<TUser>>
A System.Threading.Tasks.Task that represents the List<T> of the asynchronous query. |
GetUsernameKindAsync(TUser)
Gets the UsernameKind for the specified user
.
Declaration
public virtual async Task<UsernameKind> GetUsernameKindAsync(TUser user)
Parameters
TUser
user
The user to get the UsernameKind for. |
Returns
System.Threading.Tasks.Task<UsernameKind>
The System.Threading.Tasks.Task for the asynchronous operation, containing the UsernameKind. |
PublishEventAsync(TUser, UserInteractionEvent[])
Publishes an events
for the specified user
.
Declaration
public virtual async Task<IdentityResult> PublishEventAsync(TUser user, params UserInteractionEvent[] events)
Parameters
TUser
user
The user to publish an event for. |
UserInteractionEvent[]
events
Collection of one or more UserInteractionEvent to publish. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the operation. |
RaiseEvent(TUser, UserInteractionEvent[])
Adds an UserInteractionEvent to the user with common properties set.
Declaration
protected virtual void RaiseEvent(TUser user, params UserInteractionEvent[] events)
Parameters
TUser
user
The user to add the event to. |
UserInteractionEvent[]
events
Collection of one or more UserInteractionEvent to add. |
RemoveAuthenticatorKey(TUser)
Removes the shared key used with an authenticator app.
Declaration
public virtual async Task<IdentityResult> RemoveAuthenticatorKey(TUser user)
Parameters
TUser
user
The user to remove the key for. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
RemoveClaimsAsync(TUser, IEnumerable<Claim>)
Declaration
public override async Task<IdentityResult> RemoveClaimsAsync(TUser user, IEnumerable<Claim> claims)
Parameters
TUser
user
|
IEnumerable<System.Security.Claims.Claim>
claims
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
RemoveLoginAsync(TUser, String, String)
Attempts to remove the provided external login information from the specified user
.
and returns a flag indicating whether the removal succeed or not.
Declaration
public override Task<IdentityResult> RemoveLoginAsync(TUser user, string loginProvider, string providerKey)
Parameters
TUser
user
The user to remove the login information from. |
String
loginProvider
The login provide whose information should be removed. |
String
providerKey
The key given by the external login provider for the specified user. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
Overrides
RemovePasswordAsync(TUser)
Declaration
public override Task<IdentityResult> RemovePasswordAsync(TUser user)
Parameters
TUser
user
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
RemovePermissionAsync(TUser, String)
Removes the specified permission
from the user.
Declaration
public virtual Task<IdentityResult> RemovePermissionAsync(TUser user, string permission)
Parameters
TUser
user
The user to remove the permission from. |
String
permission
The identity of the functionality to remove permission for. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the remove. |
ResetPasswordAsync(TUser, String, String)
Declaration
public override Task<IdentityResult> ResetPasswordAsync(TUser user, string token, string newPassword)
Parameters
TUser
user
|
String
token
|
String
newPassword
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
SetEmailConfirmedAsync(TUser, Boolean)
Sets the user
email as verified.
Declaration
public virtual async Task<IdentityResult> SetEmailConfirmedAsync(TUser user, bool updateUser = true)
Parameters
TUser
user
The user that has verified the email. |
Boolean
updateUser
true to update in database; otherwise false. Default to true. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
SetLockoutEndDateAsync(TUser, Nullable<DateTimeOffset>)
Declaration
public override Task<IdentityResult> SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd)
Parameters
TUser
user
|
System.Nullable<System.DateTimeOffset>
lockoutEnd
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
SynchronizeExternalRoleAsync(TUser, ICollection<String>, IEnumerable<IRole>)
Synhronizes which external roles that the specified user
belongs to.
Declaration
public async Task<ExternalRoleSynchronizationResult> SynchronizeExternalRoleAsync(TUser user, ICollection<string> externalUserRoles, IEnumerable<IRole> allRoles)
Parameters
TUser
user
The user to synchronize external roles for. |
System.Collections.Generic.ICollection<String>
externalUserRoles
The collection of roles from an external authentication scheme. |
IEnumerable<IRole>
allRoles
All (external) roles in the application. |
Returns
System.Threading.Tasks.Task<ExternalRoleSynchronizationResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
SynchronizeRolseAsync(TUser, IEnumerable<String>, IEnumerable<String>)
Adds and removes roles from the user
.
Declaration
protected virtual async Task<ExternalRoleSynchronizationResult> SynchronizeRolseAsync(TUser user, IEnumerable<string> rolesToAdd, IEnumerable<string> rolesToRemove)
Parameters
TUser
user
The user to synchronize roles for. |
IEnumerable<String>
rolesToAdd
Roles to add to the user. |
IEnumerable<String>
rolesToRemove
Roles to remove from the user. |
Returns
System.Threading.Tasks.Task<ExternalRoleSynchronizationResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
UpdateUserAsync(TUser)
Declaration
protected override Task<IdentityResult> UpdateUserAsync(TUser user)
Parameters
TUser
user
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
UpdateUserClaims(TUser, ClaimFilterContext<TUser>)
Updates the user
's claims after claim filters have executed.
Declaration
public virtual async Task UpdateUserClaims(TUser user, ClaimFilterContext<TUser> context)
Parameters
TUser
user
The user to update. |
ClaimFilterContext<TUser>
context
The ClaimFilterContext<TUser> with claim changes. |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation. |
VerifyInvitationTokenAsyc(TUser, String)
Returns a flag indicating whether the specified user's email invitation token is valid.
Declaration
public virtual Task<bool> VerifyInvitationTokenAsyc(TUser user, string token)
Parameters
TUser
user
The user to validate the token against. |
String
token
The email invitation token to validate. |
Returns
System.Threading.Tasks.Task<Boolean>
The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the |
VerifyOneTimePasswordAsyc(TUser, String, OneTimePasswordSendService)
Returns a flag indicating whether the specified user's email confirmation token is valid.
Declaration
public virtual async Task<bool> VerifyOneTimePasswordAsyc(TUser user, string token, OneTimePasswordSendService serviceUsed)
Parameters
TUser
user
The user to validate the token against. |
String
token
The email confirmation token to validate. |
OneTimePasswordSendService
serviceUsed
The OneTimePasswordSendService used to send the one-time password to the user. |
Returns
System.Threading.Tasks.Task<Boolean>
The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the |