Class AccountUserStore<T>
Stores Identity users in concrete IUserAccount implementations
public class AccountUserStore<T> : IUserEmailStore<T>, IUserLoginStore<T>, IUserPasswordStore<T>, IUserPhoneNumberStore<T>, IUserTwoFactorStore<T>, IUserAuthenticatorKeyStore<T>, IUserTwoFactorRecoveryCodeStore<T>, IUserStore<T>, IDisposable where T : class, IUserAccount, new()
Type Parameters
T
- Inheritance
-
AccountUserStore<T>
- Implements
-
IUserStore<T>
- Inherited Members
Constructors
AccountUserStore(IServices)
public AccountUserStore(IServices services)
Parameters
servicesIServices
Methods
AddLoginAsync(T, UserLoginInfo, CancellationToken)
Adds an external UserLoginInfo to the specified user.
public Task AddLoginAsync(T user, UserLoginInfo login, CancellationToken ct)
Parameters
userTThe user to add the login to.
loginUserLoginInfoThe external UserLoginInfo to add to the specified
user.ctCancellationToken
Returns
CountCodesAsync(T, CancellationToken)
Returns how many recovery code are still valid for a user.
public Task<int> CountCodesAsync(T user, CancellationToken ct)
Parameters
userTThe user who owns the recovery code.
ctCancellationToken
Returns
CreateAsync(T, CancellationToken)
Creates the specified user in the user store.
public Task<IdentityResult> CreateAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.
DeleteAsync(T, CancellationToken)
Deletes the specified user from the user store.
public Task<IdentityResult> DeleteAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the delete operation.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FindByEmailAsync(string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
public Task<T?> FindByEmailAsync(string normalizedEmail, CancellationToken ct)
Parameters
normalizedEmailstringThe normalized email address to return the user for.
ctCancellationToken
Returns
- Task<T>
The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.
FindByIdAsync(string, CancellationToken)
Finds and returns a user, if any, who has the specified userId.
public Task<T?> FindByIdAsync(string userId, CancellationToken ct)
Parameters
userIdstringThe user ID to search for.
ctCancellationToken
Returns
- Task<T>
The Task that represents the asynchronous operation, containing the user matching the specified
userIdif it exists.
FindByLoginAsync(string, string, CancellationToken)
Retrieves the user associated with the specified login provider and login provider key.
public Task<T?> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken ct)
Parameters
loginProviderstringThe login provider who provided the
providerKey.providerKeystringThe key provided by the
loginProviderto identify a user.ctCancellationToken
Returns
- Task<T>
The Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key.
FindByNameAsync(string, CancellationToken)
Finds and returns a user, if any, who has the specified normalized user name.
public Task<T?> FindByNameAsync(string normalizedUserName, CancellationToken ct)
Parameters
normalizedUserNamestringThe normalized user name to search for.
ctCancellationToken
Returns
- Task<T>
The Task that represents the asynchronous operation, containing the user matching the specified
normalizedUserNameif it exists.
GetAuthenticatorKeyAsync(T, CancellationToken)
Get the authenticator key for the specified user.
public Task<string?> GetAuthenticatorKeyAsync(T user, CancellationToken ct)
Parameters
userTThe user whose security stamp should be set.
ctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the security stamp for the specified
user.
GetEmailAsync(T, CancellationToken)
Gets the email address for the specified user.
public Task<string?> GetEmailAsync(T user, CancellationToken ct)
Parameters
userTThe user whose email should be returned.
ctCancellationToken
Returns
- Task<string>
The task object containing the results of the asynchronous operation, the email address for the specified
user.
GetEmailConfirmedAsync(T, CancellationToken)
Gets a flag indicating whether the email address for the specified user has been verified, true if the email address is verified otherwise
false.
public Task<bool> GetEmailConfirmedAsync(T user, CancellationToken ct)
Parameters
userTThe user whose email confirmation status should be returned.
ctCancellationToken
Returns
- Task<bool>
The task object containing the results of the asynchronous operation, a flag indicating whether the email address for the specified
userhas been confirmed or not.
GetLoginsAsync(T, CancellationToken)
Retrieves the associated logins for the specified .
public Task<IList<UserLoginInfo>> GetLoginsAsync(T profile, CancellationToken ct)
Parameters
profileTctCancellationToken
Returns
- Task<IList<UserLoginInfo>>
The Task for the asynchronous operation, containing a list of UserLoginInfo for the specified
user, if any.
GetNormalizedEmailAsync(T, CancellationToken)
Returns the normalized email for the specified user.
public Task<string?> GetNormalizedEmailAsync(T user, CancellationToken ct)
Parameters
userTThe user whose email address to retrieve.
ctCancellationToken
Returns
- Task<string>
The task object containing the results of the asynchronous lookup operation, the normalized email address if any associated with the specified user.
GetNormalizedUserNameAsync(T, CancellationToken)
Gets the normalized user name for the specified user.
public Task<string?> GetNormalizedUserNameAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the normalized user name for the specified
user.
GetPasswordHashAsync(T, CancellationToken)
Gets the password hash for the specified user.
public Task<string?> GetPasswordHashAsync(T profile, CancellationToken ct)
Parameters
profileTctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, returning the password hash for the specified
user.
GetPhoneNumberAsync(T, CancellationToken)
Gets the telephone number, if any, for the specified user.
public Task<string?> GetPhoneNumberAsync(T user, CancellationToken ct)
Parameters
userTThe user whose telephone number should be retrieved.
ctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the user's telephone number, if any.
GetPhoneNumberConfirmedAsync(T, CancellationToken)
Gets a flag indicating whether the specified user's telephone number has been confirmed.
public Task<bool> GetPhoneNumberConfirmedAsync(T user, CancellationToken ct)
Parameters
userTThe user to return a flag for, indicating whether their telephone number is confirmed.
ctCancellationToken
Returns
- Task<bool>
The Task that represents the asynchronous operation, returning true if the specified
userhas a confirmed telephone number otherwise false.
GetTwoFactorEnabledAsync(T, CancellationToken)
Returns a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
public Task<bool> GetTwoFactorEnabledAsync(T user, CancellationToken ct)
Parameters
userTThe user whose two factor authentication enabled status should be set.
ctCancellationToken
Returns
- Task<bool>
The Task that represents the asynchronous operation, containing a flag indicating whether the specified
userhas two factor authentication enabled or not.
GetUserIdAsync(T, CancellationToken)
Gets the user identifier for the specified user.
public Task<string> GetUserIdAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the identifier for the specified
user.
GetUserNameAsync(T, CancellationToken)
Gets the user name for the specified user.
public Task<string?> GetUserNameAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the name for the specified
user.
HasPasswordAsync(T, CancellationToken)
Gets a flag indicating whether the specified user has a password.
public Task<bool> HasPasswordAsync(T profile, CancellationToken ct)
Parameters
profileTctCancellationToken
Returns
- Task<bool>
The Task that represents the asynchronous operation, returning true if the specified
userhas a password otherwise false.
RedeemCodeAsync(T, string, CancellationToken)
Returns whether a recovery code is valid for a user. Note: recovery codes are only valid once, and will be invalid after use.
public Task<bool> RedeemCodeAsync(T user, string code, CancellationToken ct)
Parameters
userTThe user who owns the recovery code.
codestringThe recovery code to use.
ctCancellationToken
Returns
RemoveLoginAsync(T, string, string, CancellationToken)
Attempts to remove the provided login information from the specified user.
and returns a flag indicating whether the removal succeed or not.
public Task RemoveLoginAsync(T account, string loginProvider, string providerKey, CancellationToken ct)
Parameters
accountTloginProviderstringThe login provide whose information should be removed.
providerKeystringThe key given by the external login provider for the specified user.
ctCancellationToken
Returns
ReplaceCodesAsync(T, IEnumerable<string>, CancellationToken)
Updates the recovery codes for the user while invalidating any previous recovery codes.
public Task ReplaceCodesAsync(T user, IEnumerable<string> codes, CancellationToken ct)
Parameters
userTThe user to store new recovery codes for.
codesIEnumerable<string>ctCancellationToken
Returns
- Task
The new recovery codes for the user.
SetAuthenticatorKeyAsync(T, string, CancellationToken)
Sets the authenticator key for the specified user.
public Task SetAuthenticatorKeyAsync(T user, string key, CancellationToken ct)
Parameters
userTThe user whose authenticator key should be set.
keystringThe authenticator key to set.
ctCancellationToken
Returns
SetClaimAsync<U>(T, string, U, CancellationToken)
public Task SetClaimAsync<U>(T account, string key, U value, CancellationToken ct) where U : notnull
Parameters
accountTkeystringvalueUctCancellationToken
Returns
Type Parameters
U
SetEmailAsync(T, string?, CancellationToken)
Sets the email address for a user.
public Task SetEmailAsync(T user, string? email, CancellationToken ct)
Parameters
userTThe user whose email should be set.
emailstringThe email to set.
ctCancellationToken
Returns
- Task
The task object representing the asynchronous operation.
SetEmailConfirmedAsync(T, bool, CancellationToken)
Sets the flag indicating whether the specified user's email address has been confirmed or not.
public Task SetEmailConfirmedAsync(T user, bool confirmed, CancellationToken ct)
Parameters
userTThe user whose email confirmation status should be set.
confirmedboolA flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.
ctCancellationToken
Returns
- Task
The task object representing the asynchronous operation.
SetNormalizedEmailAsync(T, string?, CancellationToken)
Sets the normalized email for the specified user.
public Task SetNormalizedEmailAsync(T user, string? normalizedEmail, CancellationToken ct)
Parameters
userTThe user whose email address to set.
normalizedEmailstringThe normalized email to set for the specified
user.ctCancellationToken
Returns
- Task
The task object representing the asynchronous operation.
SetNormalizedUserNameAsync(T, string?, CancellationToken)
Sets the given normalized name for the specified user.
public Task SetNormalizedUserNameAsync(T user, string? normalizedName, CancellationToken ct)
Parameters
userTThe user whose name should be set.
normalizedNamestringThe normalized name to set.
ctCancellationToken
Returns
SetPasswordHashAsync(T, string?, CancellationToken)
Sets the password hash for the specified user.
public Task SetPasswordHashAsync(T account, string? passwordHash, CancellationToken ct)
Parameters
accountTpasswordHashstringThe password hash to set.
ctCancellationToken
Returns
SetPhoneNumberAsync(T, string?, CancellationToken)
Sets the telephone number for the specified user.
public Task SetPhoneNumberAsync(T user, string? phoneNumber, CancellationToken ct)
Parameters
userTThe user whose telephone number should be set.
phoneNumberstringThe telephone number to set.
ctCancellationToken
Returns
SetPhoneNumberConfirmedAsync(T, bool, CancellationToken)
Sets a flag indicating if the specified user's phone number has been confirmed.
public Task SetPhoneNumberConfirmedAsync(T user, bool confirmed, CancellationToken ct)
Parameters
userTThe user whose telephone number confirmation status should be set.
confirmedboolA flag indicating whether the user's telephone number has been confirmed.
ctCancellationToken
Returns
SetTwoFactorEnabledAsync(T, bool, CancellationToken)
Sets a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
public Task SetTwoFactorEnabledAsync(T user, bool enabled, CancellationToken ct)
Parameters
userTThe user whose two factor authentication enabled status should be set.
enabledboolA flag indicating whether the specified
userhas two factor authentication enabled.ctCancellationToken
Returns
SetUserNameAsync(T, string?, CancellationToken)
Sets the given userName for the specified user.
public Task SetUserNameAsync(T account, string? userName, CancellationToken ct)
Parameters
accountTuserNamestringThe user name to set.
ctCancellationToken
Returns
UpdateAsync(T, CancellationToken)
Updates the specified user in the user store.
public Task<IdentityResult> UpdateAsync(T account, CancellationToken ct)
Parameters
accountTctCancellationToken
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.