Class BackOfficeUserStore
The user store for back office users
Inheritance
Namespace: Umbraco.Cms.Core.Security
Assembly: Umbraco.Infrastructure.dll
Syntax
public class BackOfficeUserStore : UmbracoUserStore<BackOfficeIdentityUser, IdentityRole<string>>, IUserSessionStore<BackOfficeIdentityUser>, IBackOfficeUserStore
Constructors
View SourceBackOfficeUserStore(ICoreScopeProvider, IEntityService, IExternalLoginWithKeyService, IOptionsSnapshot<GlobalSettings>, IUmbracoMapper, BackOfficeErrorDescriber, AppCaches, ITwoFactorLoginService, IUserGroupService, IUserRepository, IRuntimeState, IEventMessagesFactory, ILogger<BackOfficeUserStore>)
Initializes a new instance of the BackOfficeUserStore class.
Declaration
[ActivatorUtilitiesConstructor]
public BackOfficeUserStore(ICoreScopeProvider scopeProvider, IEntityService entityService, IExternalLoginWithKeyService externalLoginService, IOptionsSnapshot<GlobalSettings> globalSettings, IUmbracoMapper mapper, BackOfficeErrorDescriber describer, AppCaches appCaches, ITwoFactorLoginService twoFactorLoginService, IUserGroupService userGroupService, IUserRepository userRepository, IRuntimeState runtimeState, IEventMessagesFactory eventMessagesFactory, ILogger<BackOfficeUserStore> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | scopeProvider | |
| IEntityService | entityService | |
| IExternalLoginWithKeyService | externalLoginService | |
| IOptionsSnapshot<GlobalSettings> | globalSettings | |
| IUmbracoMapper | mapper | |
| BackOfficeErrorDescriber | describer | |
| AppCaches | appCaches | |
| ITwoFactorLoginService | twoFactorLoginService | |
| IUserGroupService | userGroupService | |
| IUserRepository | userRepository | |
| IRuntimeState | runtimeState | |
| IEventMessagesFactory | eventMessagesFactory | |
| ILogger<BackOfficeUserStore> | logger |
Methods
View SourceAddLoginAsync(BackOfficeIdentityUser, UserLoginInfo, CancellationToken)
Adds the login given to the specified user.
Declaration
public override Task AddLoginAsync(BackOfficeIdentityUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to add the login to. |
| UserLoginInfo | login | The login to add to the user. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
CreateAsync(BackOfficeIdentityUser, CancellationToken)
Creates the specified user in the user store.
Declaration
public override Task<IdentityResult> CreateAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to create. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the creation operation. |
DeleteAsync(BackOfficeIdentityUser, CancellationToken)
Deletes the specified user from the user store.
Declaration
public override Task<IdentityResult> DeleteAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to delete. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the update operation. |
DisableAsync(IUser)
Disables an IUser
Declaration
public Task<UserOperationStatus> DisableAsync(IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | IUser to disable. |
Returns
| Type | Description |
|---|---|
| Task<UserOperationStatus> | A task resolving into an UserOperationStatus. |
FindByEmailAsync(string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
Declaration
public override Task<BackOfficeIdentityUser?> FindByEmailAsync(string email, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ||
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> | The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address. |
FindByNameAsync(string, CancellationToken)
Finds and returns a user, if any, who has the specified normalized user name.
Declaration
public override Task<BackOfficeIdentityUser?> FindByNameAsync(string userName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userName | |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified |
FindRoleAsync(string, CancellationToken)
Return a role with the normalized name if it exists.
Declaration
protected override Task<IdentityRole<string>?> FindRoleAsync(string normalizedRoleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedRoleName | The normalized role name. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityRole<string>> | The role if it exists. |
FindUserAsync(string, CancellationToken)
Return a user with the matching userId if it exists.
Declaration
protected override Task<BackOfficeIdentityUser?> FindUserAsync(string userId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | The user's id. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> | The user if it exists. |
FindUserLoginAsync(string, string, string, CancellationToken)
Return a user login with the matching userId, provider, providerKey if it exists.
Declaration
protected override Task<IdentityUserLogin<string>?> FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | The user's id. |
| string | loginProvider | The login provider name. |
| string | providerKey | The key provided by the |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserLogin<string>> | The user login if it exists. |
FindUserLoginAsync(string, string, CancellationToken)
Return a user login with provider, providerKey if it exists.
Declaration
protected override Task<IdentityUserLogin<string>?> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | loginProvider | The login provider name. |
| string | providerKey | The key provided by the |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserLogin<string>> | The user login if it exists. |
FindUserRoleAsync(string, string, CancellationToken)
Return a user role for the userId and roleId if it exists.
Declaration
protected override Task<IdentityUserRole<string>?> FindUserRoleAsync(string userId, string roleId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | The user's id. |
| string | roleId | The role's id. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserRole<string>> | The user role if it exists. |
GetAllInGroupAsync(int)
Gets a list of IUser objects associated with a given group
Declaration
public Task<IEnumerable<IUser>> GetAllInGroupAsync(int groupId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | groupId | Id of group. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IUser>> | A task resolving into an System.Collections.Generic.IEnumerable<T> |
GetAsync(Guid)
Gets a user by it's key.
Declaration
public Task<IUser?> GetAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | Key of the user to retrieve. |
Returns
| Type | Description |
|---|---|
| Task<IUser> | Task resolving into an IUser. |
GetAsync(int)
Gets a user by Id
Declaration
public Task<IUser?> GetAsync(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the user to retrieve |
Returns
| Type | Description |
|---|---|
| Task<IUser> | A task resolving into an IUser |
GetByEmailAsync(string)
Get an IUser by email
Declaration
public Task<IUser?> GetByEmailAsync(string email)
Parameters
| Type | Name | Description |
|---|---|---|
| string | Email to use for retrieval. |
Returns
| Type | Description |
|---|---|
| Task<IUser> | A task resolving into an IUser |
GetByUserNameAsync(string)
Get an IUser by username
Declaration
public Task<IUser?> GetByUserNameAsync(string username)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | Username to use for retrieval. |
Returns
| Type | Description |
|---|---|
| Task<IUser> | A task resolving into an IUser |
GetLoginsAsync(BackOfficeIdentityUser, CancellationToken)
Retrieves the associated logins for the specified user.
Declaration
public override Task<IList<UserLoginInfo>> GetLoginsAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user whose associated logins to retrieve. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IList<UserLoginInfo>> | The System.Threading.Tasks.Task for the asynchronous operation, containing a list of Microsoft.AspNetCore.Identity.UserLoginInfo for the specified |
GetTokenAsync(BackOfficeIdentityUser, string, string, CancellationToken)
Overridden to support Umbraco's own data storage requirements
Declaration
public override Task<string?> GetTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user. |
| string | loginProvider | The authentication provider for the token. |
| string | name | The name of the token. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<string> | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Remarks
The base class's implementation of this calls into FindTokenAsync, RemoveUserTokenAsync and AddUserTokenAsync, both methods will only work with ORMs that are change tracking ORMs like EFCore.
GetTwoFactorEnabledAsync(BackOfficeIdentityUser, CancellationToken)
Returns a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
Declaration
public override Task<bool> GetTwoFactorEnabledAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user whose two factor authentication enabled status should be set. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<bool> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing a flag indicating whether the specified
|
GetUsersAsync(params Guid[]?)
Declaration
public Task<IEnumerable<IUser>> GetUsersAsync(params Guid[]? keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IUser>> |
GetUsersAsync(params int[]?)
Declaration
public Task<IEnumerable<IUser>> GetUsersAsync(params int[]? ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IUser>> |
GetUsersInRoleAsync(string, CancellationToken)
Lists all users of a given role.
Declaration
public override Task<IList<BackOfficeIdentityUser>> GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedRoleName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IList<BackOfficeIdentityUser>> |
Remarks
Identity Role names are equal to Umbraco UserGroup alias.
RemoveLoginAsync(BackOfficeIdentityUser, string, string, CancellationToken)
Removes the loginProvider given from the specified user.
Declaration
public override Task RemoveLoginAsync(BackOfficeIdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to remove the login from. |
| string | loginProvider | The login to remove from the user. |
| string | providerKey | The key provided by the |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
RemoveTokenAsync(BackOfficeIdentityUser, string, string, CancellationToken)
Overridden to support Umbraco's own data storage requirements
Declaration
public override Task RemoveTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user. |
| string | loginProvider | The authentication provider for the token. |
| string | name | The name of the token. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Remarks
The base class's implementation of this calls into FindTokenAsync, RemoveUserTokenAsync and AddUserTokenAsync, both methods will only work with ORMs that are change tracking ORMs like EFCore.
ResolveEntityIdFromIdentityId(string?)
Declaration
protected override Task<int> ResolveEntityIdFromIdentityId(string? identityId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | identityId |
Returns
| Type | Description |
|---|---|
| Task<int> |
SaveAsync(IUser)
Saves an IUser
Declaration
public Task<UserOperationStatus> SaveAsync(IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | IUser to Save |
Returns
| Type | Description |
|---|---|
| Task<UserOperationStatus> | A task resolving into an UserOperationStatus. |
SetPasswordHashAsync(BackOfficeIdentityUser, string?, CancellationToken)
Sets the password hash for a user.
Declaration
public override Task SetPasswordHashAsync(BackOfficeIdentityUser user, string? passwordHash, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to set the password hash for. |
| string | passwordHash | The password hash to set. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
SetTokenAsync(BackOfficeIdentityUser, string, string, string?, CancellationToken)
Overridden to support Umbraco's own data storage requirements
Declaration
public override Task SetTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, string? value, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user. |
| string | loginProvider | The authentication provider for the token. |
| string | name | The name of the token. |
| string | value | The value of the token. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Remarks
The base class's implementation of this calls into FindTokenAsync and AddUserTokenAsync, both methods will only work with ORMs that are change tracking ORMs like EFCore.
UpdateAsync(BackOfficeIdentityUser, CancellationToken)
Updates the specified user in the user store.
Declaration
public override Task<IdentityResult> UpdateAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | The user to update. |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the update operation. |
ValidateSessionIdAsync(string?, string?)
Validates a user's session is still valid
Declaration
public Task<bool> ValidateSessionIdAsync(string? userId, string? sessionId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | sessionId |
Returns
| Type | Description |
|---|---|
| Task<bool> |