Class UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken>
Represents a new instance of a persistence store for the specified user and role types.
public class UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken> : IUserLoginStore<TUser>, IUserRoleStore<TUser>, IUserClaimStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserEmailStore<TUser>, IUserLockoutStore<TUser>, IUserPhoneNumberStore<TUser>, IQueryableUserStore<TUser>, IUserTwoFactorStore<TUser>, IUserAuthenticationTokenStore<TUser>, IUserStore<TUser>, IDisposable where TKey : IEquatable<TKey> where TUser : class, IIdentityUser<TKey> where TRole : class, IIdentityRole<TKey> where TUserClaim : class, IIdentityUserClaim<TKey>, new() where TUserRole : class, IIdentityUserRole<TKey>, new() where TUserLogin : class, IIdentityUserLogin<TKey>, new() where TUserToken : class, IIdentityUserToken<TKey>, new()
Type Parameters
TKeyThe type of the primary key for a role.
TUserThe type representing a user.
TRoleThe type representing a role.
TUserClaimThe type representing a claim.
TUserRoleThe type representing a user role.
TUserLoginThe type representing a user external login.
TUserTokenThe type representing a user token.
- Inheritance
-
UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken>
- Implements
-
IUserLoginStore<TUser>IUserRoleStore<TUser>IUserClaimStore<TUser>IUserPasswordStore<TUser>IUserSecurityStampStore<TUser>IUserEmailStore<TUser>IUserLockoutStore<TUser>IUserPhoneNumberStore<TUser>IQueryableUserStore<TUser>IUserTwoFactorStore<TUser>IUserStore<TUser>
- Derived
Constructors
UserStore(IConnectionFactory, IdentityErrorDescriber)
Creates a new instance of UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken> .
public UserStore(IConnectionFactory factory, IdentityErrorDescriber describer = null)
Parameters
factoryIConnectionFactorydescriberIdentityErrorDescriberThe IdentityErrorDescriber used to describe store errors.
Properties
ErrorDescriber
Gets or sets the IdentityErrorDescriber for any error that occurred with the current operation.
public IdentityErrorDescriber ErrorDescriber { get; set; }
Property Value
Users
A navigation property for the users the store contains.
public virtual IQueryable<TUser> Users { get; }
Property Value
- IQueryable<TUser>
Methods
AddClaimsAsync(DataConnection, IEnumerable<TUserClaim>, CancellationToken)
Adds the claims given to the specified user.
protected virtual Task AddClaimsAsync(DataConnection dc, IEnumerable<TUserClaim> data, CancellationToken cancellationToken)
Parameters
dcDataConnectiondataIEnumerable<TUserClaim>cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddClaimsAsync(TUser, IEnumerable<Claim>, CancellationToken)
Adds the claims given to the specified user.
public Task AddClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to add the claim to.
claimsIEnumerable<Claim>The claim to add to the user.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddLoginAsync(DataConnection, TUser, UserLoginInfo, CancellationToken)
Adds the login given to the specified user.
protected virtual Task AddLoginAsync(DataConnection db, TUser user, UserLoginInfo login, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to add the login to.
loginUserLoginInfoThe login to add to the user.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddLoginAsync(TUser, UserLoginInfo, CancellationToken)
Adds the login given to the specified user.
public Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to add the login to.
loginUserLoginInfoThe login to add to the user.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddToRoleAsync(DataConnection, TUser, string, CancellationToken)
Adds the given normalizedRoleName to the specified user.
protected virtual Task AddToRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to add the role to.
normalizedRoleNamestringThe role to add.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddToRoleAsync(TUser, string, CancellationToken)
Adds the given normalizedRoleName to the specified user.
public Task AddToRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to add the role to.
normalizedRoleNamestringThe role to add.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ConvertIdFromString(string)
Converts the provided id to a strongly typed key object.
public virtual TKey ConvertIdFromString(string id)
Parameters
idstringThe id to convert.
Returns
- TKey
An instance of
TKeyrepresenting the providedid.
ConvertIdToString(TKey)
Converts the provided id to its string representation.
public virtual string ConvertIdToString(TKey id)
Parameters
idTKeyThe id to convert.
Returns
CreateAsync(DataConnection, TUser, CancellationToken)
Creates the specified user in the user store.
protected virtual Task<IdentityResult> CreateAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to create.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.
CreateAsync(TUser, CancellationToken)
Creates the specified user in the user store.
public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to create.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.
CreateUserClaim(TUser, Claim)
Create a new entity representing a user claim.
protected virtual TUserClaim CreateUserClaim(TUser user, Claim claim)
Parameters
userTUserclaimClaim
Returns
- TUserClaim
CreateUserLogin(TUser, UserLoginInfo)
Create a new entity representing a user login.
protected virtual TUserLogin CreateUserLogin(TUser user, UserLoginInfo login)
Parameters
userTUserloginUserLoginInfo
Returns
- TUserLogin
CreateUserRole(TUser, TRole)
Creates a new entity to represent a user role.
protected virtual TUserRole CreateUserRole(TUser user, TRole role)
Parameters
userTUserroleTRole
Returns
- TUserRole
CreateUserToken(TUser, string, string, string)
Create a new entity representing a user token.
protected virtual TUserToken CreateUserToken(TUser user, string loginProvider, string name, string value)
Parameters
Returns
- TUserToken
DeleteAsync(DataConnection, TUser, CancellationToken)
Deletes the specified user from the user store.
protected virtual Task<IdentityResult> DeleteAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to delete.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.
DeleteAsync(TUser, CancellationToken)
Deletes the specified user from the user store.
public Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to delete.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.
Dispose()
Dispose the store
public void Dispose()
FindByEmailAsync(DataConnection, string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
protected virtual Task<TUser> FindByEmailAsync(DataConnection db, string normalizedEmail, CancellationToken cancellationToken)
Parameters
dbDataConnectionnormalizedEmailstringThe normalized email address to return the user for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.
FindByEmailAsync(string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
public Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default)
Parameters
normalizedEmailstringThe normalized email address to return the user for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.
FindByIdAsync(DataConnection, TKey, CancellationToken)
Finds and returns a user, if any, who has the specified userId.
protected virtual Task<TUser> FindByIdAsync(DataConnection db, TKey id, CancellationToken cancellationToken)
Parameters
dbDataConnectionidTKeycancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task 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 = default)
Parameters
userIdstringThe user ID to search for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task that represents the asynchronous operation, containing the user matching the specified
userIdif it exists.
FindByLoginAsync(DataConnection, string, string, CancellationToken)
Retrieves the user associated with the specified login provider and login provider key..
protected virtual Task<TUser> FindByLoginAsync(DataConnection db, string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
dbDataConnectionloginProviderstringThe login provider who provided the
providerKey.providerKeystringThe key provided by the
loginProviderto identify a user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key.
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 = default)
Parameters
loginProviderstringThe login provider who provided the
providerKey.providerKeystringThe key provided by the
loginProviderto identify a user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key.
FindByNameAsync(DataConnection, string, CancellationToken)
Finds and returns a user, if any, who has the specified normalized user name.
protected virtual Task<TUser> FindByNameAsync(DataConnection db, string normalizedUserName, CancellationToken cancellationToken)
Parameters
dbDataConnectionnormalizedUserNamestringThe normalized user name to search for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task that represents the asynchronous operation, containing the user matching the specified
normalizedUserNameif it exists.
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 = default)
Parameters
normalizedUserNamestringThe normalized user name to search for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task that represents the asynchronous operation, containing the user matching the specified
normalizedUserNameif it exists.
GetAccessFailedCountAsync(TUser, CancellationToken)
Retrieves the current failed access count for the specified user..
public virtual Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose failed access count should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetAuthenticatorKeyAsync(TUser, CancellationToken)
Get the authenticator key for the specified user.
public virtual Task<string> GetAuthenticatorKeyAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose security stamp should be set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the security stamp for the specified
user.
GetClaimsAsync(DataConnection, TUser, CancellationToken)
Get the claims associated with the specified user as an asynchronous operation.
protected virtual Task<IList<Claim>> GetClaimsAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user whose claims should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<Claim>>
A Task<TResult> that contains the claims granted to a user.
GetClaimsAsync(TUser, CancellationToken)
Get the claims associated with the specified user as an asynchronous operation.
public Task<IList<Claim>> GetClaimsAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose claims should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<Claim>>
A Task<TResult> that contains the claims granted to a user.
GetConnection()
Gets DataConnection from supplied IConnectionFactory
protected DataConnection GetConnection()
Returns
GetContext()
Gets IDataContext from supplied IConnectionFactory
protected IDataContext GetContext()
Returns
GetEmailAsync(TUser, CancellationToken)
Gets the email address for the specified user.
public virtual Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose email should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The task object containing the results of the asynchronous operation, the email address for the specified
user.
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 virtual Task<bool> GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose email confirmation status should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
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.
GetLockoutEnabledAsync(TUser, CancellationToken)
Retrieves a flag indicating whether user lockout can enabled for the specified user.
public virtual Task<bool> GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose ability to be locked out should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, true if a user can be locked out, otherwise false.
GetLockoutEndDateAsync(TUser, CancellationToken)
Gets the last DateTimeOffset a user's last lockout expired, if any. Any time in the past should be indicates a user is not locked out.
public virtual Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose lockout date should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<DateTimeOffset?>
A Task<TResult> that represents the result of the asynchronous query, a DateTimeOffset containing the last time a user's lockout expired, if any.
GetLoginsAsync(DataConnection, TUser, CancellationToken)
Retrieves the associated logins for the specified
.protected virtual Task<IList<UserLoginInfo>> GetLoginsAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user whose associated logins to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<UserLoginInfo>>
The Task for the asynchronous operation, containing a list of UserLoginInfo for the specified
user, if any.
GetLoginsAsync(TUser, CancellationToken)
Retrieves the associated logins for the specified
.public Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose associated logins to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<UserLoginInfo>>
The Task for the asynchronous operation, containing a list of UserLoginInfo for the specified
user, if any.
GetNormalizedEmailAsync(TUser, CancellationToken)
Returns the normalized email for the specified user.
public virtual Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose email address to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
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(TUser, CancellationToken)
Gets the normalized user name for the specified user.
public virtual Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose normalized name should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the normalized user name for the specified
user.
GetPasswordHashAsync(TUser, CancellationToken)
Gets the password hash for a user.
public virtual Task<string> GetPasswordHashAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to retrieve the password hash for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A Task<TResult> that contains the password hash for the user.
GetPhoneNumberAsync(TUser, CancellationToken)
Gets the telephone number, if any, for the specified user.
public virtual Task<string> GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose telephone number should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the user's telephone number, if any.
GetPhoneNumberConfirmedAsync(TUser, CancellationToken)
Gets a flag indicating whether the specified user's telephone number has been confirmed.
public virtual Task<bool> GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to return a flag for, indicating whether their telephone number is confirmed.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, returning true if the specified
userhas a confirmed telephone number otherwise false.
GetRolesAsync(DataConnection, TUser, CancellationToken)
Retrieves the roles the specified user is a member of.
protected virtual Task<IList<string>> GetRolesAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user whose roles should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<string>>
A Task<TResult> that contains the roles the user is a member of.
GetRolesAsync(TUser, CancellationToken)
Retrieves the roles the specified user is a member of.
public Task<IList<string>> GetRolesAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose roles should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<string>>
A Task<TResult> that contains the roles the user is a member of.
GetSecurityStampAsync(TUser, CancellationToken)
Get the security stamp for the specified user.
public virtual Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose security stamp should be set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the security stamp for the specified
user.
GetTokenAsync(DataConnection, TUser, string, string, CancellationToken)
Returns the token value.
protected virtual Task<string> GetTokenAsync(DataConnection db, TUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetTokenAsync(TUser, string, string, CancellationToken)
Returns the token value.
public Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
userTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetTwoFactorEnabledAsync(TUser, CancellationToken)
Returns a flag indicating whether the specified user has two factor authentication enabled or
not,
as an asynchronous operation.
public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose two factor authentication enabled status should be set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
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(TUser, CancellationToken)
Gets the user identifier for the specified user.
public virtual Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose identifier should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the identifier for the specified
user.
GetUserNameAsync(TUser, CancellationToken)
Gets the user name for the specified user.
public virtual Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose name should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the name for the specified
user.
GetUsersForClaimAsync(Claim, CancellationToken)
Retrieves all users with the specified claim.
public Task<IList<TUser>> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken = default)
Parameters
claimClaimThe claim whose users should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetUsersInRoleAsync(DataConnection, string, CancellationToken)
Retrieves all users in the specified role.
protected virtual Task<IList<TUser>> GetUsersInRoleAsync(DataConnection db, string normalizedRoleName, CancellationToken cancellationToken)
Parameters
dbDataConnectionnormalizedRoleNamestringThe role whose users should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetUsersInRoleAsync(string, CancellationToken)
Retrieves all users in the specified role.
public Task<IList<TUser>> GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
normalizedRoleNamestringThe role whose users should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
HasPasswordAsync(TUser, CancellationToken)
Returns a flag indicating if the specified user has a password.
public virtual Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to retrieve the password hash for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
A Task<TResult> containing a flag indicating if the specified user has a password. If the user has a password the returned value with be true, otherwise it will be false.
IncrementAccessFailedCountAsync(TUser, CancellationToken)
Records that a failed access has occurred, incrementing the failed access count.
public virtual Task<int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose cancellation count should be incremented.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<int>
The Task that represents the asynchronous operation, containing the incremented failed access count.
IsInRoleAsync(DataConnection, TUser, string, CancellationToken)
Returns a flag indicating if the specified user is a member of the give normalizedRoleName.
protected virtual Task<bool> IsInRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user whose role membership should be checked.
normalizedRoleNamestringThe role to check membership of
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
A Task<TResult> containing a flag indicating if the specified user is a member of the given group. If the user is a member of the group the returned value with be true, otherwise it will be false.
IsInRoleAsync(TUser, string, CancellationToken)
Returns a flag indicating if the specified user is a member of the give normalizedRoleName.
public Task<bool> IsInRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose role membership should be checked.
normalizedRoleNamestringThe role to check membership of
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
A Task<TResult> containing a flag indicating if the specified user is a member of the given group. If the user is a member of the group the returned value with be true, otherwise it will be false.
RemoveClaimsAsync(DataConnection, TUser, IEnumerable<Claim>, CancellationToken)
Removes the claims given from the specified user.
protected virtual Task RemoveClaimsAsync(DataConnection db, TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to remove the claims from.
claimsIEnumerable<Claim>The claim to remove.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveClaimsAsync(TUser, IEnumerable<Claim>, CancellationToken)
Removes the claims given from the specified user.
public Task RemoveClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to remove the claims from.
claimsIEnumerable<Claim>The claim to remove.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveFromRoleAsync(DataConnection, TUser, string, CancellationToken)
Removes the given normalizedRoleName from the specified user.
protected virtual Task RemoveFromRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to remove the role from.
normalizedRoleNamestringThe role to remove.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveFromRoleAsync(TUser, string, CancellationToken)
Removes the given normalizedRoleName from the specified user.
public Task RemoveFromRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to remove the role from.
normalizedRoleNamestringThe role to remove.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveLoginAsync(DataConnection, TUser, string, string, CancellationToken)
Removes the loginProvider given from the specified user.
protected virtual Task RemoveLoginAsync(DataConnection db, TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to remove the login from.
loginProviderstringThe login to remove from the user.
providerKeystringThe key provided by the
loginProviderto identify a user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveLoginAsync(TUser, string, string, CancellationToken)
Removes the loginProvider given from the specified user.
public Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to remove the login from.
loginProviderstringThe login to remove from the user.
providerKeystringThe key provided by the
loginProviderto identify a user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveTokenAsync(DataConnection, TUser, string, string, CancellationToken)
Deletes a token for a user.
protected virtual Task RemoveTokenAsync(DataConnection db, TUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveTokenAsync(TUser, string, string, CancellationToken)
Deletes a token for a user.
public Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
userTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ReplaceClaimAsync(TUser, Claim, Claim, CancellationToken)
Replaces the claim on the specified user, with the
newClaim.
public Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default)
Parameters
userTUserThe role to replace the claim on.
claimClaimThe claim replace.
newClaimClaimThe new claim replacing the
claim.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ReplaceClaimAsync(TUser, Claim, Claim, CancellationToken, DataConnection)
Replaces the claim on the specified user, with the
newClaim.
protected virtual Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken, DataConnection db)
Parameters
userTUserThe role to replace the claim on.
claimClaimThe claim replace.
newClaimClaimThe new claim replacing the
claim.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
dbDataConnection
Returns
ResetAccessFailedCountAsync(TUser, CancellationToken)
Resets a user's failed access count.
public virtual Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose failed access count should be reset.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
Remarks
This is typically called after the account is successfully accessed.
SetAuthenticatorKeyAsync(TUser, string, CancellationToken)
Sets the authenticator key for the specified user.
public virtual Task SetAuthenticatorKeyAsync(TUser user, string key, CancellationToken cancellationToken)
Parameters
userTUserThe user whose authenticator key should be set.
keystringThe authenticator key to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetEmailAsync(TUser, string, CancellationToken)
Sets the email address for a user.
public virtual Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose email should be set.
emailstringThe email to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetEmailConfirmedAsync(TUser, bool, CancellationToken)
Sets the flag indicating whether the specified user's email address has been confirmed or not.
public virtual Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default)
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 CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetLockoutEnabledAsync(TUser, bool, CancellationToken)
Set the flag indicating if the specified user can be locked out..
public virtual Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose ability to be locked out should be set.
enabledboolA flag indicating if lock out can be enabled for the specified
user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetLockoutEndDateAsync(TUser, DateTimeOffset?, CancellationToken)
Locks out a user until the specified end date has passed. Setting a end date in the past immediately unlocks a user.
public virtual Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose lockout date should be set.
lockoutEndDateTimeOffset?The DateTimeOffset after which the
user's lockout should end.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetNormalizedEmailAsync(TUser, string, CancellationToken)
Sets the normalized email for the specified user.
public virtual Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose email address to set.
normalizedEmailstringThe normalized email to set for the specified
user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetNormalizedUserNameAsync(TUser, string, CancellationToken)
Sets the given normalized name for the specified user.
public virtual Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose name should be set.
normalizedNamestringThe normalized name to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPasswordHashAsync(TUser, string, CancellationToken)
Sets the password hash for a user.
public virtual Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to set the password hash for.
passwordHashstringThe password hash to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPhoneNumberAsync(TUser, string, CancellationToken)
Sets the telephone number for the specified user.
public virtual Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose telephone number should be set.
phoneNumberstringThe telephone number to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPhoneNumberConfirmedAsync(TUser, bool, CancellationToken)
Sets a flag indicating if the specified user's phone number has been confirmed..
public virtual Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose telephone number confirmation status should be set.
confirmedboolA flag indicating whether the user's telephone number has been confirmed.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetSecurityStampAsync(TUser, string, CancellationToken)
Sets the provided security stamp for the specified user.
public virtual Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose security stamp should be set.
stampstringThe security stamp to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetTokenAsync(DataConnection, TUser, string, string, string, CancellationToken)
Sets the token value for a particular user.
protected virtual Task SetTokenAsync(DataConnection db, TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
valuestringThe value of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetTokenAsync(TUser, string, string, string, CancellationToken)
Sets the token value for a particular user.
public Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
Parameters
userTUserThe user.
loginProviderstringThe authentication provider for the token.
namestringThe name of the token.
valuestringThe value of the token.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetTwoFactorEnabledAsync(TUser, bool, CancellationToken)
Sets a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
public virtual Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose two factor authentication enabled status should be set.
enabledboolA flag indicating whether the specified
userhas two factor authentication enabled.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetUserNameAsync(TUser, string, CancellationToken)
Sets the given userName for the specified user.
public virtual Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken = default)
Parameters
userTUserThe user whose name should be set.
userNamestringThe user name to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ThrowIfDisposed()
Throws if this class has been disposed.
protected void ThrowIfDisposed()
UpdateAsync(DataConnection, TUser, CancellationToken)
Updates the specified user in the user store.
protected virtual Task<IdentityResult> UpdateAsync(DataConnection db, TUser user, CancellationToken cancellationToken)
Parameters
dbDataConnectionuserTUserThe user to update.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.
UpdateAsync(TUser, CancellationToken)
Updates the specified user in the user store.
public Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
userTUserThe user to update.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.
UsersForClaimAsync(DataConnection, Claim, CancellationToken)
Retrieves all users with the specified claim.
protected virtual Task<IList<TUser>> UsersForClaimAsync(DataConnection db, Claim claim, CancellationToken cancellationToken)
Parameters
dbDataConnectionclaimClaimThe claim whose users should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.