UserStore<TUser, TRole, TContext, TKey> Class¶
Syntax¶
public class UserStore<TUser, TRole, TContext, TKey> : IUserLoginStore<TUser>, IUserRoleStore<TUser>, IUserClaimStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserEmailStore<TUser>, IUserLockoutStore<TUser>, IUserPhoneNumberStore<TUser>, IQueryableUserStore<TUser>, IUserTwoFactorStore<TUser>, IUserStore<TUser>, IDisposable where TUser : IdentityUser<TKey> where TRole : IdentityRole<TKey> where TContext : DbContext where TKey : IEquatable<TKey>
Constructors¶
-
UserStore
(TContext, Microsoft.AspNet.Identity.IdentityErrorDescriber)¶ public UserStore(TContext context, IdentityErrorDescriber describer = null)
-
Methods¶
-
AddClaimsAsync
(TUser, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task AddClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = null)
-
AddLoginAsync
(TUser, Microsoft.AspNet.Identity.UserLoginInfo, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken = null)
-
AddToRoleAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Add a user to a role
Return type: System.Threading.Tasks.Task public virtual Task AddToRoleAsync(TUser user, string roleName, CancellationToken cancellationToken = null)
-
ConvertIdFromString
(System.String)¶ Return type: {TKey} public virtual TKey ConvertIdFromString(string id)
-
ConvertIdToString
(TKey)¶ Return type: System.String public virtual string ConvertIdToString(TKey id)
-
CreateAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult} public virtual Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken = null)
-
DeleteAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult} public virtual Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken = null)
-
Dispose
()¶ Dispose the store
public void Dispose()
-
FindByEmailAsync
(System.String, System.Threading.CancellationToken)¶ Find an user by email
Return type: System.Threading.Tasks.Task{{TUser}} public virtual Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = null)
-
FindByIdAsync
(System.String, System.Threading.CancellationToken)¶ Find a user by id
Return type: System.Threading.Tasks.Task{{TUser}} public virtual Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken = null)
-
FindByLoginAsync
(System.String, System.String, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{{TUser}} public virtual Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken = null)
-
FindByNameAsync
(System.String, System.Threading.CancellationToken)¶ Find a user by normalized name
Return type: System.Threading.Tasks.Task{{TUser}} public virtual Task<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = null)
-
GetAccessFailedCountAsync
(TUser, System.Threading.CancellationToken)¶ Returns the current number of failed access attempts. This number usually will be reset whenever the password is verified or the account is locked out.
Return type: System.Threading.Tasks.Task{System.Int32} public virtual Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = null)
-
GetClaimsAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.Collections.Generic.IList{System.Security.Claims.Claim}} public virtual Task<IList<Claim>> GetClaimsAsync(TUser user, CancellationToken cancellationToken = null)
-
GetEmailAsync
(TUser, System.Threading.CancellationToken)¶ Get the user’s email
Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken = null)
-
GetEmailConfirmedAsync
(TUser, System.Threading.CancellationToken)¶ Returns whether the user email is confirmed
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken = null)
-
GetLockoutEnabledAsync
(TUser, System.Threading.CancellationToken)¶ Returns whether the user can be locked out.
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken = null)
-
GetLockoutEndDateAsync
(TUser, System.Threading.CancellationToken)¶ Returns the DateTimeOffset that represents the end of a user’s lockout, any time in the past should be considered not locked out.
Return type: System.Threading.Tasks.Task{System.Nullable{System.DateTimeOffset}} public virtual Task<DateTimeOffset? > GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken = null)
-
GetLoginsAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.Collections.Generic.IList{Microsoft.AspNet.Identity.UserLoginInfo}} public virtual Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken = null)
-
GetNormalizedEmailAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken = null)
-
GetNormalizedUserNameAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = null)
-
GetPasswordHashAsync
(TUser, System.Threading.CancellationToken)¶ Get the password hash for a user
Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetPasswordHashAsync(TUser user, CancellationToken cancellationToken = null)
-
GetPhoneNumberAsync
(TUser, System.Threading.CancellationToken)¶ Get a user’s phone number
Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken = null)
-
GetPhoneNumberConfirmedAsync
(TUser, System.Threading.CancellationToken)¶ Returns whether the user phoneNumber is confirmed
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken = null)
-
GetRolesAsync
(TUser, System.Threading.CancellationToken)¶ Get the names of the roles a user is a member of
Return type: System.Threading.Tasks.Task{System.Collections.Generic.IList{System.String}} public virtual Task<IList<string>> GetRolesAsync(TUser user, CancellationToken cancellationToken = null)
-
GetSecurityStampAsync
(TUser, System.Threading.CancellationToken)¶ Get the security stamp for a user
Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken = null)
-
GetTwoFactorEnabledAsync
(TUser, System.Threading.CancellationToken)¶ Gets whether two factor authentication is enabled for the user
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken = null)
-
GetUserIdAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken = null)
-
GetUserNameAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{System.String} public virtual Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken = null)
-
GetUsersForClaimAsync
(System.Security.Claims.Claim, System.Threading.CancellationToken)¶ Get all users with given claim
Return type: System.Threading.Tasks.Task{System.Collections.Generic.IList{{TUser}}} public virtual Task<IList<TUser>> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken = null)
-
GetUsersInRoleAsync
(System.String, System.Threading.CancellationToken)¶ Get all users in given role
Return type: System.Threading.Tasks.Task{System.Collections.Generic.IList{{TUser}}} public virtual Task<IList<TUser>> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken = null)
-
HasPasswordAsync
(TUser, System.Threading.CancellationToken)¶ Returns true if the user has a password set
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken = null)
-
IncrementAccessFailedCountAsync
(TUser, System.Threading.CancellationToken)¶ Used to record when an attempt to access the user has failed
Return type: System.Threading.Tasks.Task{System.Int32} public virtual Task<int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = null)
-
IsInRoleAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Returns true if the user is in the named role
Return type: System.Threading.Tasks.Task{System.Boolean} public virtual Task<bool> IsInRoleAsync(TUser user, string roleName, CancellationToken cancellationToken = null)
-
RemoveClaimsAsync
(TUser, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task RemoveClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = null)
-
RemoveFromRoleAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Remove a user from a role
Return type: System.Threading.Tasks.Task public virtual Task RemoveFromRoleAsync(TUser user, string roleName, CancellationToken cancellationToken = null)
-
RemoveLoginAsync
(TUser, System.String, System.String, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = null)
-
ReplaceClaimAsync
(TUser, System.Security.Claims.Claim, System.Security.Claims.Claim, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = null)
-
ResetAccessFailedCountAsync
(TUser, System.Threading.CancellationToken)¶ Used to reset the account access count, typically after the account is successfully accessed
Return type: System.Threading.Tasks.Task public virtual Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = null)
-
SetEmailAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Set the user email
Return type: System.Threading.Tasks.Task public virtual Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken = null)
-
SetEmailConfirmedAsync
(TUser, System.Boolean, System.Threading.CancellationToken)¶ Set IsConfirmed on the user
Return type: System.Threading.Tasks.Task public virtual Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = null)
-
SetLockoutEnabledAsync
(TUser, System.Boolean, System.Threading.CancellationToken)¶ Sets whether the user can be locked out.
Return type: System.Threading.Tasks.Task public virtual Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = null)
-
SetLockoutEndDateAsync
(TUser, System.Nullable<System.DateTimeOffset>, System.Threading.CancellationToken)¶ Locks a user out until the specified end date (set to a past date, to unlock a user)
Return type: System.Threading.Tasks.Task public virtual Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken = null)
-
SetNormalizedEmailAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken = null)
-
SetNormalizedUserNameAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken = null)
-
SetPasswordHashAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Set the password hash for a user
Return type: System.Threading.Tasks.Task public virtual Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken = null)
-
SetPhoneNumberAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Set the user’s phone number
Return type: System.Threading.Tasks.Task public virtual Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken = null)
-
SetPhoneNumberConfirmedAsync
(TUser, System.Boolean, System.Threading.CancellationToken)¶ Set PhoneNumberConfirmed on the user
Return type: System.Threading.Tasks.Task public virtual Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = null)
-
SetSecurityStampAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Set the security stamp for the user
Return type: System.Threading.Tasks.Task public virtual Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken = null)
-
SetTwoFactorEnabledAsync
(TUser, System.Boolean, System.Threading.CancellationToken)¶ Set whether two factor authentication is enabled for the user
Return type: System.Threading.Tasks.Task public virtual Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = null)
-
SetUserNameAsync
(TUser, System.String, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task public virtual Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken = null)
-
UpdateAsync
(TUser, System.Threading.CancellationToken)¶ Return type: System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult} public virtual Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken = null)
-
Properties¶
-
AutoSaveChanges
()¶ If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
Return type: System.Boolean public bool AutoSaveChanges { get; set; }
-
Context
()¶ Return type: {TContext} public TContext Context { get; }
-
ErrorDescriber
()¶ Used to generate public API error messages
Return type: Microsoft.AspNet.Identity.IdentityErrorDescriber public IdentityErrorDescriber ErrorDescriber { get; set; }
-
Users
()¶ Return type: System.Linq.IQueryable{{TUser}} public virtual IQueryable<TUser> Users { get; }
-