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
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 19.")]
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 | Provides database transaction scopes for data operations. |
| IEntityService | entityService | Service for managing Umbraco entities. |
| IExternalLoginWithKeyService | externalLoginService | Handles external login providers with key support. |
| IOptionsSnapshot<GlobalSettings> | globalSettings | The global configuration settings for Umbraco. |
| IUmbracoMapper | mapper | Maps between domain and view models in Umbraco. |
| BackOfficeErrorDescriber | describer | Provides error descriptions for back office user operations. |
| AppCaches | appCaches | Provides access to application-level caches. |
| ITwoFactorLoginService | twoFactorLoginService | Service for managing two-factor authentication for users. |
| IUserGroupService | userGroupService | Service for managing user groups in the back office. |
| IUserRepository | userRepository | Repository for accessing and persisting user data. |
| IRuntimeState | runtimeState | Represents the current runtime state of the Umbraco application. |
| IEventMessagesFactory | eventMessagesFactory | Factory for creating event message collections. |
| ILogger<BackOfficeUserStore> | logger | Logger instance for logging operations related to the user store. |
BackOfficeUserStore(ICoreScopeProvider, IEntityService, IExternalLoginWithKeyService, IOptionsSnapshot<GlobalSettings>, IUmbracoMapper, BackOfficeErrorDescriber, AppCaches, ITwoFactorLoginService, IUserGroupService, IUserRepository, IRuntimeState, IEventMessagesFactory, ILogger<BackOfficeUserStore>, IBackOfficeUserReader)
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, IBackOfficeUserReader backOfficeUserReader)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | scopeProvider | Provides database transaction scopes for data operations. |
| IEntityService | entityService | Service for managing Umbraco entities. |
| IExternalLoginWithKeyService | externalLoginService | Handles external login providers with key support. |
| IOptionsSnapshot<GlobalSettings> | globalSettings | The global configuration settings for Umbraco. |
| IUmbracoMapper | mapper | Maps between domain and view models in Umbraco. |
| BackOfficeErrorDescriber | describer | Provides error descriptions for back office user operations. |
| AppCaches | appCaches | Provides access to application-level caches. |
| ITwoFactorLoginService | twoFactorLoginService | Service for managing two-factor authentication for users. |
| IUserGroupService | userGroupService | Service for managing user groups in the back office. |
| IUserRepository | userRepository | Repository for accessing and persisting user data. |
| IRuntimeState | runtimeState | Represents the current runtime state of the Umbraco application. |
| IEventMessagesFactory | eventMessagesFactory | Factory for creating event message collections. |
| ILogger<BackOfficeUserStore> | logger | Logger instance for logging operations related to the user store. |
| IBackOfficeUserReader | backOfficeUserReader | The shared reader used for back office user lookups. |
Methods
View SourceAddLoginAsync(BackOfficeIdentityUser, UserLoginInfo, CancellationToken)
Declaration
public override Task AddLoginAsync(BackOfficeIdentityUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| UserLoginInfo | login | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
CreateAsync(BackOfficeIdentityUser, CancellationToken)
Declaration
public override Task<IdentityResult> CreateAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> |
DeleteAsync(BackOfficeIdentityUser, CancellationToken)
Declaration
public override Task<IdentityResult> DeleteAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> |
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)
Declaration
public override Task<BackOfficeIdentityUser?> FindByEmailAsync(string email, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ||
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> |
FindByNameAsync(string, CancellationToken)
Declaration
public override Task<BackOfficeIdentityUser?> FindByNameAsync(string userName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> |
FindRoleAsync(string, CancellationToken)
Declaration
protected override Task<IdentityRole<string>?> FindRoleAsync(string normalizedRoleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedRoleName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityRole<string>> |
FindUserAsync(string, CancellationToken)
Declaration
protected override Task<BackOfficeIdentityUser?> FindUserAsync(string userId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<BackOfficeIdentityUser> |
FindUserLoginAsync(string, string, string, CancellationToken)
Declaration
protected override Task<IdentityUserLogin<string>?> FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | loginProvider | |
| string | providerKey | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserLogin<string>> |
FindUserLoginAsync(string, string, CancellationToken)
Declaration
protected override Task<IdentityUserLogin<string>?> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | loginProvider | |
| string | providerKey | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserLogin<string>> |
FindUserRoleAsync(string, string, CancellationToken)
Declaration
protected override Task<IdentityUserRole<string>?> FindUserRoleAsync(string userId, string roleId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | roleId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityUserRole<string>> |
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)
Asynchronously retrieves a user by their unique identifier.
Declaration
public Task<IUser?> GetAsync(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The unique identifier of the user to retrieve. |
Returns
| Type | Description |
|---|---|
| Task<IUser> | A task representing the asynchronous operation. The task result contains the IUser if found; otherwise, |
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)
Declaration
public override Task<IList<UserLoginInfo>> GetLoginsAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IList<UserLoginInfo>> |
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 | |
| string | loginProvider | |
| string | name | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
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)
Declaration
public override Task<bool> GetTwoFactorEnabledAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
GetUsersAsync(params Guid[]?)
Asynchronously retrieves the users with the specified IDs.
Declaration
public Task<IEnumerable<IUser>> GetUsersAsync(params Guid[]? keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IUser>> | A task that represents the asynchronous operation. The task result contains an System.Collections.Generic.IEnumerable<T> of users matching the specified IDs. |
GetUsersAsync(params int[]?)
Asynchronously retrieves the users with the specified IDs.
Declaration
public Task<IEnumerable<IUser>> GetUsersAsync(params int[]? ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids | An array of user IDs to retrieve. If null or empty, an empty collection is returned. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IUser>> | A task that represents the asynchronous operation. The task result contains an System.Collections.Generic.IEnumerable<T> of users matching the specified IDs. |
GetUsersInRoleAsync(string, CancellationToken)
Returns all users that belong to the specified role.
Declaration
public override Task<IList<BackOfficeIdentityUser>> GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | normalizedRoleName | The normalized name of the role (UserGroup alias) whose users are to be listed. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<IList<BackOfficeIdentityUser>> | A task that represents the asynchronous operation. The task result contains a list of BackOfficeIdentityUser objects in the specified role. |
Remarks
Identity role names correspond to Umbraco UserGroup aliases.
RemoveLoginAsync(BackOfficeIdentityUser, string, string, CancellationToken)
Declaration
public override Task RemoveLoginAsync(BackOfficeIdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| string | loginProvider | |
| string | providerKey | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
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 | |
| string | loginProvider | |
| string | name | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
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)
Declaration
public override Task SetPasswordHashAsync(BackOfficeIdentityUser user, string? passwordHash, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| string | passwordHash | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
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 | |
| string | loginProvider | |
| string | name | |
| string | value | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
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)
Declaration
public override Task<IdentityResult> UpdateAsync(BackOfficeIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| BackOfficeIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IdentityResult> |
ValidateSessionIdAsync(string?, string?)
Asynchronously determines whether the specified user's session is still valid.
Declaration
public Task<bool> ValidateSessionIdAsync(string? userId, string? sessionId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | The ID of the user whose session validity is being checked. |
| string | sessionId | The session ID to validate. |
Returns
| Type | Description |
|---|---|
| Task<bool> | A task that represents the asynchronous operation. The task result is |