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
memberInfoProvider
IMemberInfoProviderProvider for MemberInfo management.
memberExternalLoginInfoProvider
IMemberExternalLoginInfoProviderProvider for ExternalLoginInfo management.
Exceptions
- ArgumentNullException
memberInfoProvider
ormemberExternalLoginInfoProvider
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
TUserThe user to add the login to.
login
UserLoginInfoThe external Microsoft.AspNetCore.Identity.UserLoginInfo to add to the specified
user
.cancellationToken
CancellationTokenThe 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
orlogin
is null.
CreateAsync(TUser, CancellationToken)
Creates the specified user
in the user store.
public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken)
Parameters
user
TUserThe user to create.
cancellationToken
CancellationTokenThe 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
TUserUser.
cancellationToken
CancellationTokenThe 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
boolDescribes 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
stringThe normalized email address to return the user for.
cancellationToken
CancellationTokenThe 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
intThe user identifier.
cancellationToken
CancellationTokenThe 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
stringThe user ID to search for.
cancellationToken
CancellationTokenThe 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
stringThe login provider who provided the
providerKey
.providerKey
stringThe key provided by the
loginProvider
to identify a user.cancellationToken
CancellationTokenThe 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
stringThe normalized user name to search for.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email should be returned.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email confirmation status should be returned.
cancellationToken
CancellationTokenThe 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
TUserThe user whose associated logins to retrieve.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email address to retrieve.
cancellationToken
CancellationTokenThe 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
TUserThe user whose normalized name should be retrieved.
cancellationToken
CancellationTokenThe 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
TUserThe user whose password hash to retrieve.
cancellationToken
CancellationTokenThe 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
TUserThe user whose security stamp should be set.
cancellationToken
CancellationTokenThe 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
TUserThe user whose identifier should be retrieved.
cancellationToken
CancellationTokenThe 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
TUserThe user whose name should be retrieved.
cancellationToken
CancellationTokenThe 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
TUserThe user to return a flag for, indicating whether they have a password or not.
cancellationToken
CancellationTokenThe 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 specifieduser
has a password; otherwisefalse
.
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
TUserThe user to remove the login information from.
loginProvider
stringThe login provide whose information should be removed.
providerKey
stringThe key given by the external login provider for the specified user.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email should be set.
email
stringThe email to set.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email confirmation status should be set.
confirmed
boolA flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.
cancellationToken
CancellationTokenThe 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
TUserThe user whose email address to set.
normalizedEmail
stringThe normalized email to set for the specified
user
.cancellationToken
CancellationTokenThe 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
TUserThe user whose name should be set.
normalizedName
stringThe normalized name to set.
cancellationToken
CancellationTokenThe 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
TUserThe user whose password hash to set.
passwordHash
stringThe password hash to set.
cancellationToken
CancellationTokenThe 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
TUserThe user whose security stamp should be set.
stamp
stringThe security stamp to set.
cancellationToken
CancellationTokenThe 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
TUserThe user whose name should be set.
userName
stringThe user name to set.
cancellationToken
CancellationTokenThe 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
TUserThe user to update.
cancellationToken
CancellationTokenThe 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.