Class UserStore<TUser, TRole, TUserLogin, TContext>
Represents a new instance of a persistence store for the specified user and role types.
Inheritance
Inherited Members
Namespace: IRM.AspNetCore.Identity.EntityFrameworkCore
Assembly: IRM.AspNetCore.Identity.EntityFrameworkCore.dll
Syntax
public class UserStore<TUser, TRole, TUserLogin, TContext> : UserStore<TUser, TRole, TContext, Guid, IdentityUserClaim<Guid>, IdentityUserRole<Guid>, TUserLogin, IdentityUserToken<Guid>, IdentityRoleClaim<Guid>>, IUserLoginStore<TUser>, IUserClaimStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserEmailStore<TUser>, IUserLockoutStore<TUser>, IUserPhoneNumberStore<TUser>, IQueryableUserStore<TUser>, IUserTwoFactorStore<TUser>, IUserAuthenticationTokenStore<TUser>, IUserAuthenticatorKeyStore<TUser>, IUserTwoFactorRecoveryCodeStore<TUser>, IUserRoleStore<TUser>, IProtectedUserStore<TUser>, IUserStore<TUser>, IUserStore<TUser>, IUserStore<TUser>, IDisposable, IEventStore, IPermissionStore where TUser : IdentityUser, new()
where TRole : IdentityRole, new()
where TUserLogin : IdentityUserLogin<Guid>, new()
where TContext : DbContext
Type Parameters
TUser
The type representing a user. |
TRole
The type representing a role. |
TUserLogin
The type representing a user external login. |
TContext
The type of the data context class used to access the store. |
Constructors
UserStore(TContext, ILogger<UserStore<TUser, TRole, TUserLogin, TContext>>, IAsyncEventSourceRepository, IdentityErrorDescriber)
Creates a new instance of UserStore<TUser, TRole, TUserLogin, TContext>.
Declaration
public UserStore(TContext context, ILogger<UserStore<TUser, TRole, TUserLogin, TContext>> logger, IAsyncEventSourceRepository eventSourceRepository = null, IdentityErrorDescriber describer = null)
Parameters
TContext
context
The context used to access the store. |
Microsoft.Extensions.Logging.ILogger<UserStore<TUser, TRole, TUserLogin, TContext>>
logger
The logger used to log messages, warnings and errors. |
IAsyncEventSourceRepository
eventSourceRepository
The IAsyncEventSourceRepository used to handle events. |
Microsoft.AspNetCore.Identity.IdentityErrorDescriber
describer
The Microsoft.AspNetCore.Identity.IdentityErrorDescriber used to describe store errors. |
Properties
EventSourceRepository
Gets the IAsyncEventSourceRepository used to handle events.
Declaration
protected IAsyncEventSourceRepository EventSourceRepository { get; }
Property Value
IAsyncEventSourceRepository
|
Logger
Gets the logger used to log messages, warnings and errors.
Declaration
protected ILogger Logger { get; }
Property Value
Microsoft.Extensions.Logging.ILogger
|
Methods
ConvertIdFromString(String)
Declaration
public override Guid ConvertIdFromString(string id)
Parameters
String
id
|
Returns
System.Guid
|
Overrides
CreateAsync(TUser, CancellationToken)
Declaration
public override async Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
Implements
CreateUserClaim(TUser, Claim)
Declaration
protected override IdentityUserClaim<Guid> CreateUserClaim(TUser user, Claim claim)
Parameters
TUser
user
|
System.Security.Claims.Claim
claim
|
Returns
Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>
|
Overrides
CreateUserLogin(TUser, UserLoginInfo)
Declaration
protected override TUserLogin CreateUserLogin(TUser user, UserLoginInfo login)
Parameters
TUser
user
|
Microsoft.AspNetCore.Identity.UserLoginInfo
login
|
Returns
TUserLogin
|
Overrides
CreateUserRole(TUser, TRole)
Declaration
protected override IdentityUserRole<Guid> CreateUserRole(TUser user, TRole role)
Parameters
TUser
user
|
TRole
role
|
Returns
Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>
|
Overrides
CreateUserToken(TUser, String, String, String)
Declaration
protected override IdentityUserToken<Guid> CreateUserToken(TUser user, string loginProvider, string name, string value)
Parameters
TUser
user
|
String
loginProvider
|
String
name
|
String
value
|
Returns
Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>
|
Overrides
DeleteAsync(TUser, CancellationToken)
Declaration
public override async Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|
Overrides
Implements
FindByEmailAsync(String, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
Declaration
public override Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
normalizedEmail
The normalized email address to return the user for. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<TUser>
The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address. |
Overrides
FindByIdAsync(String, CancellationToken)
Finds and returns a user, if any, who has the specified userId
.
Declaration
public override Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
userId
The user ID to search for. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<TUser>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified |
Overrides
Implements
FindByLoginAsync(String, String, CancellationToken)
Retrieves the user associated with the specified login provider and login provider key..
Declaration
public override async Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
loginProvider
The login provider who provided the |
String
providerKey
The key provided by the |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<TUser>
The System.Threading.Tasks.Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key. |
Overrides
FindByNameAsync(String, CancellationToken)
Finds and returns a user, if any, who has the specified normalized user name.
Declaration
public override Task<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
normalizedUserName
The normalized user name to search for. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<TUser>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified |
Overrides
Implements
GetDefaultRolesForNewUserAsync(TUser, CancellationToken)
Gets all default roles that should be added to new users.
Declaration
protected virtual Task<List<TRole>> GetDefaultRolesForNewUserAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<List<TRole>>
The System.Threading.Tasks.Task for the asynchronous operation, containing the list of default roles, if any, that should be added to new users. |
GetLoginsAsync(TUser, CancellationToken)
Declaration
public override Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IList<Microsoft.AspNetCore.Identity.UserLoginInfo>>
|
Overrides
GetSystemUsersAsync(CancellationToken)
Gets all users that represents systems.
Declaration
public virtual Task<List<TUser>> GetSystemUsersAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
System.Threading.Tasks.Task<List<TUser>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the users that represents systems. |
Implements
GetUser(Guid, CancellationToken)
Gets a user with default includes for this store implementation.
Declaration
protected virtual Task<TUser> GetUser(Guid id, CancellationToken cancellationToken = default(CancellationToken))
Parameters
System.Guid
id
The identity of the user to get. |
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
System.Threading.Tasks.Task<TUser>
A task that represents the asynchronous operation. |
GetUser(Expression<Func<TUser, Boolean>>, CancellationToken)
Gets a user with default includes for this store implementation.
Declaration
protected virtual Task<TUser> GetUser(Expression<Func<TUser, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Expression<System.Func<TUser, Boolean>>
predicate
A function to test each element for a condition. |
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
System.Threading.Tasks.Task<TUser>
A task that represents the asynchronous operation. |
RemoveAuthenticatorKey(TUser, CancellationToken)
Removes the shared key used with an authenticator app.
Declaration
public virtual Task RemoveAuthenticatorKey(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
The user to remove the key for. |
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation. |
Implements
RemoveFromRoleAsync(TUser, String, CancellationToken)
Declaration
public override async Task RemoveFromRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
String
normalizedRoleName
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task
|
Overrides
SaveEvents(IEventSourced, CancellationToken)
Saves all registered events in aggregate
.
Declaration
public virtual async Task<IdentityResult> SaveEvents(IEventSourced user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
IEventSourced
user
|
System.Threading.CancellationToken
cancellationToken
A System.Threading.CancellationToken to observe while waiting for the task to complete. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the operation. |
Implements
SetEmailConfirmedAsync(TUser, Boolean, CancellationToken)
Declaration
public override Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
Boolean
confirmed
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task
|
Overrides
SetPasswordHashAsync(TUser, String, CancellationToken)
Declaration
public override Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
String
passwordHash
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task
|
Overrides
SetPhoneNumberConfirmedAsync(TUser, Boolean, CancellationToken)
Declaration
public override Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
Boolean
confirmed
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task
|
Overrides
UpdateAsync(TUser, CancellationToken)
Declaration
public override async Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TUser
user
|
System.Threading.CancellationToken
cancellationToken
|
Returns
System.Threading.Tasks.Task<IdentityResult>
|