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
-
objectApplicationUserStore<TUser>
- Extension Methods
Constructors
ApplicationUserStore(IMemberInfoProvider, IMemberExternalLoginInfoProvider)
Initializes a new instance of the ApplicationUserStore<TUser>.
public ApplicationUserStore(IMemberInfoProvider memberInfoProvider, IMemberExternalLoginInfoProvider memberExternalLoginInfoProvider)
Parameters
memberInfoProviderIMemberInfoProviderProvider for MemberInfo management.
memberExternalLoginInfoProviderIMemberExternalLoginInfoProviderProvider for ExternalLoginInfo management.
Exceptions
- ArgumentNullException
memberInfoProviderormemberExternalLoginInfoProvideris 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
userTUserThe user to add the login to.
loginUserLoginInfoThe external Microsoft.AspNetCore.Identity.UserLoginInfo to add to the specified
user.cancellationTokenCancellationTokenThe 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
userorloginis null.
CreateAsync(TUser, CancellationToken)
Creates the specified user in the user store.
public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to create.
cancellationTokenCancellationTokenThe 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
useris null.
DeleteAsync(TUser, CancellationToken)
Deletes the user.
public Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserUser.
cancellationTokenCancellationTokenThe 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
useris 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
disposingboolDescribes 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
normalizedEmailstringThe normalized email address to return the user for.
cancellationTokenCancellationTokenThe 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
userIdintThe user identifier.
cancellationTokenCancellationTokenThe 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
userIdif 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
userIdstringThe user ID to search for.
cancellationTokenCancellationTokenThe 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
userIdif it exists.
Exceptions
- ArgumentException
userIdis 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
loginProviderstringThe login provider who provided the
providerKey.providerKeystringThe key provided by the
loginProviderto identify a user.cancellationTokenCancellationTokenThe 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
normalizedUserNamestringThe normalized user name to search for.
cancellationTokenCancellationTokenThe 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
normalizedUserNameif it exists.
GetEmailAsync(TUser, CancellationToken)
Gets the email address for the specified user.
public Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email should be returned.
cancellationTokenCancellationTokenThe 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
useris 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
userTUserThe user whose email confirmation status should be returned.
cancellationTokenCancellationTokenThe 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
userhas been confirmed or not.
Exceptions
- ArgumentNullException
useris null.
GetLoginsAsync(TUser, CancellationToken)
Retrieves the associated logins for the specified .
public Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose associated logins to retrieve.
cancellationTokenCancellationTokenThe 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
useris null.
GetNormalizedEmailAsync(TUser, CancellationToken)
Returns the normalized email for the specified user.
public Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email address to retrieve.
cancellationTokenCancellationTokenThe 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
userTUserThe user whose normalized name should be retrieved.
cancellationTokenCancellationTokenThe 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
userTUserThe user whose password hash to retrieve.
cancellationTokenCancellationTokenThe 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
useris 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
userTUserThe user whose security stamp should be set.
cancellationTokenCancellationTokenThe 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
useris null.
GetUserIdAsync(TUser, CancellationToken)
Gets the user identifier for the specified user.
public Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose identifier should be retrieved.
cancellationTokenCancellationTokenThe 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
useris null.
GetUserNameAsync(TUser, CancellationToken)
Gets the user name for the specified user.
public Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose name should be retrieved.
cancellationTokenCancellationTokenThe 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
useris null.
HasPasswordAsync(TUser, CancellationToken)
Gets a flag indicating whether the specified user has a password.
public Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to return a flag for, indicating whether they have a password or not.
cancellationTokenCancellationTokenThe 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
trueif the specifieduserhas a password; otherwisefalse.
Exceptions
- ArgumentNullException
useris 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
userTUserThe user to remove the login information from.
loginProviderstringThe login provide whose information should be removed.
providerKeystringThe key given by the external login provider for the specified user.
cancellationTokenCancellationTokenThe 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
useris null.
SetEmailAsync(TUser, string, CancellationToken)
Sets the email address for a user.
public Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email should be set.
emailstringThe email to set.
cancellationTokenCancellationTokenThe 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
useris 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
userTUserThe 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.
cancellationTokenCancellationTokenThe 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
useris null.
SetNormalizedEmailAsync(TUser, string, CancellationToken)
Sets the normalized email for the specified user.
public Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email address to set.
normalizedEmailstringThe normalized email to set for the specified
user.cancellationTokenCancellationTokenThe 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
userTUserThe user whose name should be set.
normalizedNamestringThe normalized name to set.
cancellationTokenCancellationTokenThe 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
userTUserThe user whose password hash to set.
passwordHashstringThe password hash to set.
cancellationTokenCancellationTokenThe 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
useris null.
SetSecurityStampAsync(TUser, string, CancellationToken)
Sets the provided security stamp for the specified user.
public Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken)
Parameters
userTUserThe user whose security stamp should be set.
stampstringThe security stamp to set.
cancellationTokenCancellationTokenThe 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
useris null.
SetUserNameAsync(TUser, string, CancellationToken)
Sets the given userName for the specified user.
public Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken)
Parameters
userTUserThe user whose name should be set.
userNamestringThe user name to set.
cancellationTokenCancellationTokenThe 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
useris 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
userTUserThe user to update.
cancellationTokenCancellationTokenThe 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
useris null.- InvalidOperationException
Thrown when user is not found.