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
TKey
The type of the primary key for a role.
TUser
The type representing a user.
TRole
The type representing a role.
TUserClaim
The type representing a claim.
TUserRole
The type representing a user role.
TUserLogin
The type representing a user external login.
TUserToken
The 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
factory
IConnectionFactorydescriber
IdentityErrorDescriberThe 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
dc
DataConnectiondata
IEnumerable<TUserClaim>cancellationToken
CancellationTokenThe 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
user
TUserThe user to add the claim to.
claims
IEnumerable<Claim>The claim to add to the user.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to add the login to.
login
UserLoginInfoThe login to add to the user.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to add the login to.
login
UserLoginInfoThe login to add to the user.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to add the role to.
normalizedRoleName
stringThe role to add.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to add the role to.
normalizedRoleName
stringThe role to add.
cancellationToken
CancellationTokenThe 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
id
stringThe id to convert.
Returns
- TKey
An instance of
TKey
representing the providedid
.
ConvertIdToString(TKey)
Converts the provided id
to its string representation.
public virtual string ConvertIdToString(TKey id)
Parameters
id
TKeyThe 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
db
DataConnectionuser
TUserThe user to create.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to create.
cancellationToken
CancellationTokenThe 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
user
TUserclaim
Claim
Returns
- TUserClaim
CreateUserLogin(TUser, UserLoginInfo)
Create a new entity representing a user login.
protected virtual TUserLogin CreateUserLogin(TUser user, UserLoginInfo login)
Parameters
user
TUserlogin
UserLoginInfo
Returns
- TUserLogin
CreateUserRole(TUser, TRole)
Creates a new entity to represent a user role.
protected virtual TUserRole CreateUserRole(TUser user, TRole role)
Parameters
user
TUserrole
TRole
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
db
DataConnectionuser
TUserThe user to delete.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to delete.
cancellationToken
CancellationTokenThe 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
db
DataConnectionnormalizedEmail
stringThe normalized email address to return the user for.
cancellationToken
CancellationTokenThe 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
normalizedEmail
stringThe normalized email address to return the user for.
cancellationToken
CancellationTokenThe 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
db
DataConnectionid
TKeycancellationToken
CancellationTokenThe 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
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 = default)
Parameters
userId
stringThe user ID to search for.
cancellationToken
CancellationTokenThe 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
userId
if 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
db
DataConnectionloginProvider
stringThe login provider who provided the
providerKey
.providerKey
stringThe key provided by the
loginProvider
to identify a user.cancellationToken
CancellationTokenThe 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
loginProvider
stringThe login provider who provided the
providerKey
.providerKey
stringThe key provided by the
loginProvider
to identify a user.cancellationToken
CancellationTokenThe 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
db
DataConnectionnormalizedUserName
stringThe normalized user name to search for.
cancellationToken
CancellationTokenThe 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
normalizedUserName
if 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
normalizedUserName
stringThe normalized user name to search for.
cancellationToken
CancellationTokenThe 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
normalizedUserName
if 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
user
TUserThe user whose failed access count should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose security stamp should be set.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user whose claims should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose claims should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose email should be returned.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose email confirmation status should be returned.
cancellationToken
CancellationTokenThe 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
user
has 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
user
TUserThe user whose ability to be locked out should be returned.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose lockout date should be retrieved.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user whose associated logins to retrieve.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose associated logins to retrieve.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose email address to retrieve.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose normalized name should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to retrieve the password hash for.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose telephone number should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to return a flag for, indicating whether their telephone number is confirmed.
cancellationToken
CancellationTokenThe 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
user
has 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
db
DataConnectionuser
TUserThe user whose roles should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose roles should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose security stamp should be set.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose two factor authentication enabled status should be set.
cancellationToken
CancellationTokenThe 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
user
has 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
user
TUserThe user whose identifier should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose name should be retrieved.
cancellationToken
CancellationTokenThe 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
claim
ClaimThe claim whose users should be retrieved.
cancellationToken
CancellationTokenThe 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
db
DataConnectionnormalizedRoleName
stringThe role whose users should be retrieved.
cancellationToken
CancellationTokenThe 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
normalizedRoleName
stringThe role whose users should be retrieved.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to retrieve the password hash for.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose cancellation count should be incremented.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user whose role membership should be checked.
normalizedRoleName
stringThe role to check membership of
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose role membership should be checked.
normalizedRoleName
stringThe role to check membership of
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to remove the claims from.
claims
IEnumerable<Claim>The claim to remove.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to remove the claims from.
claims
IEnumerable<Claim>The claim to remove.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to remove the role from.
normalizedRoleName
stringThe role to remove.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to remove the role from.
normalizedRoleName
stringThe role to remove.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to remove the login from.
loginProvider
stringThe login to remove from the user.
providerKey
stringThe key provided by the
loginProvider
to identify a user.cancellationToken
CancellationTokenThe 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
user
TUserThe user to remove the login from.
loginProvider
stringThe login to remove from the user.
providerKey
stringThe key provided by the
loginProvider
to identify a user.cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe role to replace the claim on.
claim
ClaimThe claim replace.
newClaim
ClaimThe new claim replacing the
claim
.cancellationToken
CancellationTokenThe 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
user
TUserThe role to replace the claim on.
claim
ClaimThe claim replace.
newClaim
ClaimThe new claim replacing the
claim
.cancellationToken
CancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
db
DataConnection
Returns
ResetAccessFailedCountAsync(TUser, CancellationToken)
Resets a user's failed access count.
public virtual Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)
Parameters
user
TUserThe user whose failed access count should be reset.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose authenticator key should be set.
key
stringThe authenticator key to set.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose email should be set.
email
stringThe email to set.
cancellationToken
CancellationTokenThe 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
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 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
user
TUserThe user whose ability to be locked out should be set.
enabled
boolA flag indicating if lock out can be enabled for the specified
user
.cancellationToken
CancellationTokenThe 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
user
TUserThe user whose lockout date should be set.
lockoutEnd
DateTimeOffset?The DateTimeOffset after which the
user
's lockout should end.cancellationToken
CancellationTokenThe 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
user
TUserThe user whose email address to set.
normalizedEmail
stringThe normalized email to set for the specified
user
.cancellationToken
CancellationTokenThe 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
user
TUserThe user whose name should be set.
normalizedName
stringThe normalized name to set.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to set the password hash for.
passwordHash
stringThe password hash to set.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose telephone number should be set.
phoneNumber
stringThe telephone number to set.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose telephone number confirmation status should be set.
confirmed
boolA flag indicating whether the user's telephone number has been confirmed.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose security stamp should be set.
stamp
stringThe security stamp to set.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
value
stringThe value of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe user.
loginProvider
stringThe authentication provider for the token.
name
stringThe name of the token.
value
stringThe value of the token.
cancellationToken
CancellationTokenThe 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
user
TUserThe user whose two factor authentication enabled status should be set.
enabled
boolA flag indicating whether the specified
user
has two factor authentication enabled.cancellationToken
CancellationTokenThe 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
user
TUserThe user whose name should be set.
userName
stringThe user name to set.
cancellationToken
CancellationTokenThe 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
db
DataConnectionuser
TUserThe user to update.
cancellationToken
CancellationTokenThe 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
user
TUserThe user to update.
cancellationToken
CancellationTokenThe 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
db
DataConnectionclaim
ClaimThe claim whose users should be retrieved.
cancellationToken
CancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.