Table of Contents

Class AccountUserStore<T>

Namespace
The.Web.Security
Assembly
Instagile.Web.dll

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
Inherited Members

Constructors

AccountUserStore(IServices)

public AccountUserStore(IServices services)

Parameters

services IServices

Methods

AddLoginAsync(T, UserLoginInfo, CancellationToken)

Adds an external UserLoginInfo to the specified user.

public Task AddLoginAsync(T user, UserLoginInfo login, CancellationToken ct)

Parameters

user T

The user to add the login to.

login UserLoginInfo

The external UserLoginInfo to add to the specified user.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

CountCodesAsync(T, CancellationToken)

Returns how many recovery code are still valid for a user.

public Task<int> CountCodesAsync(T user, CancellationToken ct)

Parameters

user T

The user who owns the recovery code.

ct CancellationToken

Returns

Task<int>

The number of valid recovery codes for the user..

CreateAsync(T, CancellationToken)

Creates the specified user in the user store.

public Task<IdentityResult> CreateAsync(T account, CancellationToken ct)

Parameters

account T
ct CancellationToken

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

account T
ct CancellationToken

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

normalizedEmail string

The normalized email address to return the user for.

ct CancellationToken

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

userId string

The user ID to search for.

ct CancellationToken

Returns

Task<T>

The Task that represents the asynchronous operation, containing the user matching the specified userId if 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

loginProvider string

The login provider who provided the providerKey.

providerKey string

The key provided by the loginProvider to identify a user.

ct CancellationToken

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

normalizedUserName string

The normalized user name to search for.

ct CancellationToken

Returns

Task<T>

The Task that represents the asynchronous operation, containing the user matching the specified normalizedUserName if it exists.

GetAuthenticatorKeyAsync(T, CancellationToken)

Get the authenticator key for the specified user.

public Task<string?> GetAuthenticatorKeyAsync(T user, CancellationToken ct)

Parameters

user T

The user whose security stamp should be set.

ct CancellationToken

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

user T

The user whose email should be returned.

ct CancellationToken

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

user T

The user whose email confirmation status should be returned.

ct CancellationToken

Returns

Task<bool>

The task object containing the results of the asynchronous operation, a flag indicating whether the email address for the specified user has been confirmed or not.

GetLoginsAsync(T, CancellationToken)

Retrieves the associated logins for the specified .

public Task<IList<UserLoginInfo>> GetLoginsAsync(T profile, CancellationToken ct)

Parameters

profile T
ct CancellationToken

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

user T

The user whose email address to retrieve.

ct CancellationToken

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

account T
ct CancellationToken

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

profile T
ct CancellationToken

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

user T

The user whose telephone number should be retrieved.

ct CancellationToken

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

user T

The user to return a flag for, indicating whether their telephone number is confirmed.

ct CancellationToken

Returns

Task<bool>

The Task that represents the asynchronous operation, returning true if the specified user has 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

user T

The user whose two factor authentication enabled status should be set.

ct CancellationToken

Returns

Task<bool>

The Task that represents the asynchronous operation, containing a flag indicating whether the specified user has 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

account T
ct CancellationToken

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

account T
ct CancellationToken

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

profile T
ct CancellationToken

Returns

Task<bool>

The Task that represents the asynchronous operation, returning true if the specified user has 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

user T

The user who owns the recovery code.

code string

The recovery code to use.

ct CancellationToken

Returns

Task<bool>

True if the recovery code was found for the user.

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

account T
loginProvider string

The login provide whose information should be removed.

providerKey string

The key given by the external login provider for the specified user.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

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

user T

The user to store new recovery codes for.

codes IEnumerable<string>
ct CancellationToken

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

user T

The user whose authenticator key should be set.

key string

The authenticator key to set.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

SetClaimAsync<U>(T, string, U, CancellationToken)

public Task SetClaimAsync<U>(T account, string key, U value, CancellationToken ct) where U : notnull

Parameters

account T
key string
value U
ct CancellationToken

Returns

Task

Type Parameters

U

SetEmailAsync(T, string?, CancellationToken)

Sets the email address for a user.

public Task SetEmailAsync(T user, string? email, CancellationToken ct)

Parameters

user T

The user whose email should be set.

email string

The email to set.

ct CancellationToken

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

user T

The user whose email confirmation status should be set.

confirmed bool

A flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.

ct CancellationToken

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

user T

The user whose email address to set.

normalizedEmail string

The normalized email to set for the specified user.

ct CancellationToken

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

user T

The user whose name should be set.

normalizedName string

The normalized name to set.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

SetPasswordHashAsync(T, string?, CancellationToken)

Sets the password hash for the specified user.

public Task SetPasswordHashAsync(T account, string? passwordHash, CancellationToken ct)

Parameters

account T
passwordHash string

The password hash to set.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

SetPhoneNumberAsync(T, string?, CancellationToken)

Sets the telephone number for the specified user.

public Task SetPhoneNumberAsync(T user, string? phoneNumber, CancellationToken ct)

Parameters

user T

The user whose telephone number should be set.

phoneNumber string

The telephone number to set.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

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

user T

The user whose telephone number confirmation status should be set.

confirmed bool

A flag indicating whether the user's telephone number has been confirmed.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

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

user T

The user whose two factor authentication enabled status should be set.

enabled bool

A flag indicating whether the specified user has two factor authentication enabled.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

SetUserNameAsync(T, string?, CancellationToken)

Sets the given userName for the specified user.

public Task SetUserNameAsync(T account, string? userName, CancellationToken ct)

Parameters

account T
userName string

The user name to set.

ct CancellationToken

Returns

Task

The Task that represents the asynchronous operation.

UpdateAsync(T, CancellationToken)

Updates the specified user in the user store.

public Task<IdentityResult> UpdateAsync(T account, CancellationToken ct)

Parameters

account T
ct CancellationToken

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.