Table of Contents

Class ApplicationUserStore<TUser>

Namespace
Kentico.Membership
Assembly
Kentico.Membership.dll

Implements basic user management operations.

public class ApplicationUserStore<TUser> where TUser : ApplicationUser, new()

Type Parameters

TUser
Inheritance
object
ApplicationUserStore<TUser>
Extension Methods

Constructors

ApplicationUserStore(IMemberInfoProvider, IMemberExternalLoginInfoProvider)

Initializes a new instance of the ApplicationUserStore<TUser>.

public ApplicationUserStore(IMemberInfoProvider memberInfoProvider, IMemberExternalLoginInfoProvider memberExternalLoginInfoProvider)

Parameters

memberInfoProvider IMemberInfoProvider

Provider for MemberInfo management.

memberExternalLoginInfoProvider IMemberExternalLoginInfoProvider

Provider for ExternalLoginInfo management.

Exceptions

ArgumentNullException

memberInfoProvider or memberExternalLoginInfoProvider is null.

Methods

AddLoginAsync(TUser, UserLoginInfo, CancellationToken)

Adds an external Microsoft.AspNetCore.Identity.UserLoginInfo to the specified user.

public Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken)

Parameters

user TUser

The user to add the login to.

login UserLoginInfo

The external Microsoft.AspNetCore.Identity.UserLoginInfo to add to the specified user.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user or login is null.

CreateAsync(TUser, CancellationToken)

Creates the specified user in the user store.

public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user to create.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the creation operation.

Exceptions

ArgumentNullException

user is null.

DeleteAsync(TUser, CancellationToken)

Deletes the user.

public Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

User.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the update operation.

Exceptions

ArgumentNullException

user is null.

Dispose()

Performs tasks to dispose the user store.

public void Dispose()

Dispose(bool)

Disposes the user store.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Describes whether or not should the managed resources be disposed.

FindByEmailAsync(string, CancellationToken)

Gets the user, if any, associated with the specified, normalized email address.

public Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken)

Parameters

normalizedEmail string

The normalized email address to return the user for.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The System.Threading.Tasks.Task<TResult> containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.

FindByIdAsync(int, CancellationToken)

Finds and returns a user, if any, who has the specified userId.

public Task<TUser> FindByIdAsync(int userId, CancellationToken cancellationToken)

Parameters

userId int

The user identifier.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the user matching the specified userId if it exists.

FindByIdAsync(string, CancellationToken)

Finds and returns a user, if any, who has the specified userId.

public Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken)

Parameters

userId string

The user ID to search for.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the user matching the specified userId if it exists.

Exceptions

ArgumentException

userId is empty or non integer.

FindByLoginAsync(string, string, CancellationToken)

Retrieves the user associated with the specified login provider and login provider key.

public Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)

Parameters

loginProvider string

The login provider who provided the providerKey.

providerKey string

The key provided by the loginProvider to identify a user.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The System.Threading.Tasks.Task<TResult> 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<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)

Parameters

normalizedUserName string

The normalized user name to search for.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the user matching the specified normalizedUserName if it exists.

GetEmailAsync(TUser, CancellationToken)

Gets the email address for the specified user.

public Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email should be returned.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> containing the results of the asynchronous operation, the email address for the specified user.

Exceptions

ArgumentNullException

user is null.

GetEmailConfirmedAsync(TUser, 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(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email confirmation status should be returned.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The System.Threading.Tasks.Task<TResult> containing the results of the asynchronous operation, a flag indicating whether the email address for the specified user has been confirmed or not.

Exceptions

ArgumentNullException

user is null.

GetLoginsAsync(TUser, CancellationToken)

Retrieves the associated logins for the specified .

public Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose associated logins to retrieve.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<UserLoginInfo>>

The System.Threading.Tasks.Task<TResult> for the asynchronous operation, containing a list of Microsoft.AspNetCore.Identity.UserLoginInfo for the specified user, if any.

Exceptions

ArgumentNullException

user is null.

GetNormalizedEmailAsync(TUser, CancellationToken)

Returns the normalized email for the specified user.

public Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email address to retrieve.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> containing the results of the asynchronous lookup operation, the normalized email address if any associated with the specified user.

GetNormalizedUserNameAsync(TUser, CancellationToken)

Gets the normalized user name for the specified user.

public Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose normalized name should be retrieved.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the normalized user name for the specified user.

GetPasswordHashAsync(TUser, CancellationToken)

Gets the password hash for the specified user.

public Task<string> GetPasswordHashAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose password hash to retrieve.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, returning the password hash for the specified user.

Exceptions

ArgumentNullException

user is null.

InvalidOperationException

Thrown when the user is not found.

GetSecurityStampAsync(TUser, CancellationToken)

Get the security stamp for the specified user.

public Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose security stamp should be set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the security stamp for the specified user.

Exceptions

ArgumentNullException

user is null.

GetUserIdAsync(TUser, CancellationToken)

Gets the user identifier for the specified user.

public Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose identifier should be retrieved.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the identifier for the specified user.

Exceptions

ArgumentNullException

user is null.

GetUserNameAsync(TUser, CancellationToken)

Gets the user name for the specified user.

public Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose name should be retrieved.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the name for the specified user.

Exceptions

ArgumentNullException

user is null.

HasPasswordAsync(TUser, CancellationToken)

Gets a flag indicating whether the specified user has a password.

public Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user to return a flag for, indicating whether they have a password or not.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, returning true if the specified user has a password; otherwise false.

Exceptions

ArgumentNullException

user is null.

InvalidOperationException

Thrown when the user is not found.

RemoveLoginAsync(TUser, 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(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken)

Parameters

user TUser

The user to remove the login information from.

loginProvider string

The login provide whose information should be removed.

providerKey string

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

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

SetEmailAsync(TUser, string, CancellationToken)

Sets the email address for a user.

public Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email should be set.

email string

The email to set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

InvalidOperationException

Thrown when user is not found.

SetEmailConfirmedAsync(TUser, bool, CancellationToken)

Sets the flag indicating whether the specified user's email address has been confirmed or not.

public Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken)

Parameters

user TUser

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.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task representing the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

SetNormalizedEmailAsync(TUser, string, CancellationToken)

Sets the normalized email for the specified user.

public Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email address to set.

normalizedEmail string

The normalized email to set for the specified user.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task representing the asynchronous operation.

SetNormalizedUserNameAsync(TUser, string, CancellationToken)

Sets the given normalized name for the specified user.

public Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken)

Parameters

user TUser

The user whose name should be set.

normalizedName string

The normalized name to set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

SetPasswordHashAsync(TUser, string, CancellationToken)

Sets the password hash for the specified user.

public Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken)

Parameters

user TUser

The user whose password hash to set.

passwordHash string

The password hash to set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

SetSecurityStampAsync(TUser, string, CancellationToken)

Sets the provided security stamp for the specified user.

public Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken)

Parameters

user TUser

The user whose security stamp should be set.

stamp string

The security stamp to set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

SetUserNameAsync(TUser, string, CancellationToken)

Sets the given userName for the specified user.

public Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken)

Parameters

user TUser

The user whose name should be set.

userName string

The user name to set.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The System.Threading.Tasks.Task that represents the asynchronous operation.

Exceptions

ArgumentNullException

user is null.

ThrowIfDisposed()

Throws if this class has been disposed.

protected void ThrowIfDisposed()

UpdateAsync(TUser, CancellationToken)

Updates the specified user in the user store.

public Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user to update.

cancellationToken CancellationToken

The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The System.Threading.Tasks.Task<TResult> that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the update operation.

Exceptions

ArgumentNullException

user is null.

InvalidOperationException

Thrown when user is not found.