Class IdentityUserStore<T>
Implements the user store interfaces for an identity user.
Inherited Members
Namespace: DataWeb.Identity
Assembly: DataWeb.Core.dll
Syntax
public class IdentityUserStore<T> : IUserStore<T>, IUserPasswordStore<T>, IUserRoleStore<T>, IUserEmailStore<T>, IUserLockoutStore<T>, IUserPhoneNumberStore<T>, IUserLoginStore<T>, IUserTwoFactorStore<T>, IUserSecurityStampStore<T>, IUserAuthenticatorKeyStore<T>, IUserStore<T>, IDisposable where T : AppIdentityUser
Type Parameters
| Name | Description |
|---|---|
| T | The type of identity user to store. |
Remarks
Initializes a new instance of the IdentityUserStore<T> class.
Constructors
IdentityUserStore(IUserService)
Implements the user store interfaces for an identity user.
Declaration
public IdentityUserStore(IUserService userService)
Parameters
| Type | Name | Description |
|---|---|---|
| IUserService | userService | The user service to use for user management operations. |
Remarks
Initializes a new instance of the IdentityUserStore<T> class.
Methods
AddLoginAsync(T, UserLoginInfo, CancellationToken)
Adds a user login with the specified login provider to the specified user.
Declaration
public Task AddLoginAsync(T user, UserLoginInfo login, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to add the login to. |
| UserLoginInfo | login | The UserLoginInfo to add. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
AddToRoleAsync(T, string, CancellationToken)
Adds a user to a role.
Declaration
public Task AddToRoleAsync(T user, string roleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to add to the role. |
| string | roleName | The name of the role to add the user to. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
CreateAsync(T, CancellationToken)
Creates a new user.
Declaration
public Task<IdentityResult> CreateAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to create. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | A task representing the asynchronous operation. |
DeleteAsync(T, CancellationToken)
Deletes an existing user.
Declaration
public Task<IdentityResult> DeleteAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to delete. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | A task representing the asynchronous operation. |
Dispose()
Disposes the object.
Declaration
public void Dispose()
FindByEmailAsync(string, CancellationToken)
Finds and returns a user by their normalized email.
Declaration
public Task<T> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedEmail | The normalized email address to search for. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task<T> | A task that represents the asynchronous operation. The task result contains the user matching the specified normalized email if it exists. |
FindByIdAsync(string, CancellationToken)
Finds a user by their Id.
Declaration
public Task<T> FindByIdAsync(string userId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | The Id of the user to find. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<T> | A task representing the asynchronous operation. |
FindByLoginAsync(string, string, CancellationToken)
Retrieves the user associated with the specified login provider and key.
Declaration
public Task<T> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | loginProvider | The login provider. |
| string | providerKey | The login key. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<T> | The user associated with the specified login provider and key. |
FindByNameAsync(string, CancellationToken)
Finds a user by their name.
Declaration
public Task<T> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedUserName | The name of the user to find. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<T> | A task representing the asynchronous operation. |
GetAccessFailedCountAsync(T, CancellationToken)
Gets the number of failed access attempts for the user.
Declaration
public Task<int> GetAccessFailedCountAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<int> | A Task<TResult> representing the result of the asynchronous operation. |
GetAuthenticatorKeyAsync(T, CancellationToken)
Get the authenticator key for the specified user.
Declaration
public Task<string> GetAuthenticatorKeyAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose security stamp should be set. |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<string> | The Task that represents the asynchronous operation, containing the security stamp for the specified |
GetEmailAsync(T, CancellationToken)
Gets the email address for the specified user.
Declaration
public Task<string> GetEmailAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose email address to retrieve. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | The email address for the specified user. |
GetEmailConfirmedAsync(T, CancellationToken)
Gets a flag indicating whether the specified user's email address has been confirmed.
Declaration
public Task<bool> GetEmailConfirmedAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose email confirmation status to retrieve. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A flag indicating whether the specified user's email address has been confirmed. |
GetLockoutEnabledAsync(T, CancellationToken)
Determines whether the user is lockout enabled.
Declaration
public Task<bool> GetLockoutEnabledAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A Task<TResult> representing the result of the asynchronous operation. |
GetLockoutEndDateAsync(T, CancellationToken)
Retrieves the DateTimeOffset when the user's lockout ends (if any).
Declaration
public Task<DateTimeOffset?> GetLockoutEndDateAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to retrieve the lockout end date for. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<DateTimeOffset?> | The DateTimeOffset when the user's lockout ends, if any. |
GetLoginsAsync(T, CancellationToken)
Retrieves the logins associated with the specified user.
Declaration
public Task<IList<UserLoginInfo>> GetLoginsAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose logins to retrieve. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IList<UserLoginInfo>> | The IList<T> of UserLoginInfo instances for the specified user. |
GetNormalizedEmailAsync(T, CancellationToken)
Gets the normalized email address for the specified user.
Declaration
public Task<string> GetNormalizedEmailAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose normalized email address to retrieve. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | The normalized email address for the specified user. |
GetNormalizedUserNameAsync(T, CancellationToken)
Gets the normalized user name for the specified user.
Declaration
public Task<string> GetNormalizedUserNameAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose normalized name should be retrieved. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation. The task result contains the normalized name of the specified user. |
GetPasswordHashAsync(T, CancellationToken)
Gets the password hash for a user.
Declaration
public Task<string> GetPasswordHashAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to get the password hash for. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation. The task result contains the password hash for the user. |
GetPhoneNumberAsync(T, CancellationToken)
Retrieves the phone number, if any, for the specified user.
Declaration
public Task<string> GetPhoneNumberAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to retrieve the phone number for. |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<string> | The Task that represents the asynchronous operation, containing the phone number, if any, for the specified |
GetPhoneNumberConfirmedAsync(T, CancellationToken)
Retrieves a flag indicating whether the specified user phone number has been confirmed.
Declaration
public Task<bool> GetPhoneNumberConfirmedAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to retrieve the phone number confirmation flag for. |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<bool> | The Task that represents the asynchronous operation, containing a flag indicating whether the specified |
GetRolesAsync(T, CancellationToken)
Gets the roles for a user.
Declaration
public Task<IList<string>> GetRolesAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to get the roles for. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IList<string>> | A task that represents the asynchronous operation. The task result contains the roles for the user. |
GetSecurityStampAsync(T, CancellationToken)
Retrieves the security stamp for the specified user.
Declaration
public Task<string> GetSecurityStampAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose security stamp to retrieve. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<string> | A Task<TResult> representing the asynchronous operation, containing the security stamp for the specified user. |
GetTwoFactorEnabledAsync(T, CancellationToken)
Retrieves a flag indicating whether two-factor authentication is enabled for the specified user.
Declaration
public Task<bool> GetTwoFactorEnabledAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to retrieve the flag for. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A Task<TResult> representing the asynchronous operation, containing a flag indicating whether two-factor authentication is enabled for the specified user. |
GetUserIdAsync(T, CancellationToken)
Gets the user Id for the specified user.
Declaration
public Task<string> GetUserIdAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose Id should be retrieved. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation. The task result contains the Id of the specified user. |
GetUserNameAsync(T, CancellationToken)
Gets the user name for the specified user.
Declaration
public Task<string> GetUserNameAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose name should be retrieved. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation. The task result contains the name of the specified user. |
GetUsersInRoleAsync(string, CancellationToken)
Gets a list of users who belong to the specified role.
Declaration
public Task<IList<T>> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roleName | The name of the role. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IList<T>> | A list of users who belong to the specified role. |
HasPasswordAsync(T, CancellationToken)
Determines whether the user has a password.
Declaration
public Task<bool> HasPasswordAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to check. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A task that represents the asynchronous operation. The task result contains true if the user has a password; otherwise, false. |
IncrementAccessFailedCountAsync(T, CancellationToken)
Increments the access failed count for the user.
Declaration
public Task<int> IncrementAccessFailedCountAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<int> | A Task<TResult> representing the result of the asynchronous operation. |
IsInRoleAsync(T, string, CancellationToken)
Determines whether a user is in a role.
Declaration
public Task<bool> IsInRoleAsync(T user, string roleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to check. |
| string | roleName | The name of the role to check for the user. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A task that represents the asynchronous operation. The task result contains true if the user is in the role; otherwise, false. |
RemoveFromRoleAsync(T, string, CancellationToken)
Removes a user from a role.
Declaration
public Task RemoveFromRoleAsync(T user, string roleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to remove from the role. |
| string | roleName | The name of the role to remove the user from. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
RemoveLoginAsync(T, string, string, CancellationToken)
Removes the user's login with the specified login provider.
Declaration
public Task RemoveLoginAsync(T user, string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to remove the login from. |
| string | loginProvider | The login provider to remove. |
| string | providerKey | The provider key to remove. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
ResetAccessFailedCountAsync(T, CancellationToken)
Resets the access failed count for the user.
Declaration
public Task ResetAccessFailedCountAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the result of the asynchronous operation. |
SetAuthenticatorKeyAsync(T, string, CancellationToken)
Sets the authenticator key for the specified user.
Declaration
public Task SetAuthenticatorKeyAsync(T user, string key, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose authenticator key should be set. |
| string | key | The authenticator key to set. |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The Task that represents the asynchronous operation. |
SetEmailAsync(T, string, CancellationToken)
Sets the email address for the specified user.
Declaration
public Task SetEmailAsync(T user, string email, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose email address to set. |
| string | The email address to set for the user. |
|
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetEmailConfirmedAsync(T, bool, CancellationToken)
Sets a flag indicating whether the specified user's email address has been confirmed.
Declaration
public Task SetEmailConfirmedAsync(T user, bool confirmed, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose email confirmation status to set. |
| bool | confirmed | A flag indicating whether the email address has been confirmed. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetLockoutEnabledAsync(T, bool, CancellationToken)
Enables or disables the user lockout feature.
Declaration
public Task SetLockoutEnabledAsync(T user, bool enabled, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user. |
| bool | enabled | A boolean indicating whether lockout is enabled for the user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the result of the asynchronous operation. |
SetLockoutEndDateAsync(T, DateTimeOffset?, CancellationToken)
Sets the DateTimeOffset when the user's lockout ends.
Declaration
public Task SetLockoutEndDateAsync(T user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the lockout end date for. |
| DateTimeOffset? | lockoutEnd | The DateTimeOffset when the user's lockout should end. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetNormalizedEmailAsync(T, string, CancellationToken)
Sets the normalized email for the specified user. This implementation does nothing since the UserService does not use normalized emails.
Declaration
public Task SetNormalizedEmailAsync(T user, string normalizedEmail, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the normalized email for. |
| string | normalizedEmail | The normalized email to set. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetNormalizedUserNameAsync(T, string, CancellationToken)
Sets the normalized user name for the specified user.
Declaration
public Task SetNormalizedUserNameAsync(T user, string normalizedName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose normalized name should be set. |
| string | normalizedName | The normalized name to set for the user. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetPasswordHashAsync(T, string, CancellationToken)
Sets the password hash for a user.
Declaration
public Task SetPasswordHashAsync(T user, string passwordHash, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the password hash for. |
| string | passwordHash | The password hash to set for the user. |
| CancellationToken | cancellationToken | A cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetPhoneNumberAsync(T, string, CancellationToken)
Sets the phone number for the specified user.
Declaration
public Task SetPhoneNumberAsync(T user, string phoneNumber, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the phone number for. |
| string | phoneNumber | The phone number to set for the specified |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task |
SetPhoneNumberConfirmedAsync(T, bool, CancellationToken)
Sets a flag indicating if the specified user phone number has been confirmed.
Declaration
public Task SetPhoneNumberConfirmedAsync(T user, bool confirmed, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the phone number confirmation flag for. |
| bool | confirmed | A flag indicating if the phone number has been confirmed for the specified |
| CancellationToken | cancellationToken | The CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The Task that represents the asynchronous operation. |
SetSecurityStampAsync(T, string, CancellationToken)
Sets the security stamp for the specified user.
Declaration
public Task SetSecurityStampAsync(T user, string stamp, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the security stamp for. |
| string | stamp | The security stamp to set. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetTwoFactorEnabledAsync(T, bool, CancellationToken)
Sets a flag indicating whether two-factor authentication is enabled for the specified user.
Declaration
public Task SetTwoFactorEnabledAsync(T user, bool enabled, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to set the flag for. |
| bool | enabled | A flag indicating whether two-factor authentication is enabled for the specified user. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | The Task that represents the asynchronous operation. |
SetUserNameAsync(T, string, CancellationToken)
Sets the user name for the specified user.
Declaration
public Task SetUserNameAsync(T user, string userName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user whose name should be set. |
| string | userName | The name to set for the user. |
| CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
UpdateAsync(T, CancellationToken)
Updates an existing user.
Declaration
public Task<IdentityResult> UpdateAsync(T user, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| T | user | The user to update. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | A task representing the asynchronous operation. |