Class MemberUserStore
A custom user store that uses Umbraco member data
Inheritance
Namespace: Umbraco.Cms.Core.Security
Assembly: Umbraco.Infrastructure.dll
Syntax
public class MemberUserStore : UmbracoUserStore<MemberIdentityUser, UmbracoIdentityRole>, IMemberUserStore
Constructors
View SourceMemberUserStore(IMemberService, IUmbracoMapper, ICoreScopeProvider, IdentityErrorDescriber, IExternalLoginWithKeyService, ITwoFactorLoginService, IPublishedMemberCache)
Initializes a new instance of the MemberUserStore class for the members identity store
Declaration
[ActivatorUtilitiesConstructor]
public MemberUserStore(IMemberService memberService, IUmbracoMapper mapper, ICoreScopeProvider scopeProvider, IdentityErrorDescriber describer, IExternalLoginWithKeyService externalLoginService, ITwoFactorLoginService twoFactorLoginService, IPublishedMemberCache memberCache)
Parameters
| Type | Name | Description |
|---|---|---|
| IMemberService | memberService | The member service |
| IUmbracoMapper | mapper | The mapper for properties |
| ICoreScopeProvider | scopeProvider | The scope provider |
| IdentityErrorDescriber | describer | The error describer |
| IExternalLoginWithKeyService | externalLoginService | The external login service |
| ITwoFactorLoginService | twoFactorLoginService | The two factor login service |
| IPublishedMemberCache | memberCache |
Fields
View SourceCancelledIdentityErrorCode
Declaration
public const string CancelledIdentityErrorCode = "CancelledIdentityErrorUserStore"
Field Value
| Type | Description |
|---|---|
| string |
Methods
View SourceAddLoginAsync(MemberIdentityUser, UserLoginInfo, CancellationToken)
Adds the login given to the specified user.
Declaration
public override Task AddLoginAsync(MemberIdentityUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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(MemberIdentityUser, CancellationToken)
Creates the specified user in the user store.
Declaration
public override Task<IdentityResult> CreateAsync(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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(MemberIdentityUser, CancellationToken)
Deletes the specified user from the user store.
Declaration
public override Task<IdentityResult> DeleteAsync(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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. |
FindByEmailAsync(string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
Declaration
public override Task<MemberIdentityUser?> 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<MemberIdentityUser> | 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<MemberIdentityUser?> 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<MemberIdentityUser> | 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<UmbracoIdentityRole?> FindRoleAsync(string roleName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roleName | |
| CancellationToken | cancellationToken | The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task<UmbracoIdentityRole> | The role if it exists. |
FindUserAsync(string, CancellationToken)
Return a user with the matching userId if it exists.
Declaration
protected override Task<MemberIdentityUser?> 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<MemberIdentityUser> | 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. |
GetLoginsAsync(MemberIdentityUser, CancellationToken)
Retrieves the associated logins for the specified user.
Declaration
public override Task<IList<UserLoginInfo>> GetLoginsAsync(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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 |
GetPublishedMember(MemberIdentityUser?)
Declaration
public IPublishedContent? GetPublishedMember(MemberIdentityUser? user)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | user |
Returns
| Type | Description |
|---|---|
| IPublishedContent |
GetRolesAsync(MemberIdentityUser, CancellationToken)
Gets a list of role names the specified user belongs to.
Declaration
public override Task<IList<string>> GetRolesAsync(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | user | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IList<string>> |
Remarks
This lazy loads the roles for the member
GetTokenAsync(MemberIdentityUser, string, string, CancellationToken)
Overridden to support Umbraco's own data storage requirements
Declaration
public override Task<string?> GetTokenAsync(MemberIdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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(MemberIdentityUser, 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(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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
|
GetUsersInRoleAsync(string, CancellationToken)
Lists all users of a given role.
Declaration
public override Task<IList<MemberIdentityUser>> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roleName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IList<MemberIdentityUser>> |
IsInRoleAsync(MemberIdentityUser, string, CancellationToken)
Returns true if a user is in the role
Declaration
public override Task<bool> IsInRoleAsync(MemberIdentityUser user, string roleName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | user | |
| string | roleName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
RemoveLoginAsync(MemberIdentityUser, string, string, CancellationToken)
Removes the loginProvider given from the specified user.
Declaration
public override Task RemoveLoginAsync(MemberIdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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. |
ResolveEntityIdFromIdentityId(string?)
Declaration
protected override Task<int> ResolveEntityIdFromIdentityId(string? identityId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | identityId |
Returns
| Type | Description |
|---|---|
| Task<int> |
SetTokenAsync(MemberIdentityUser, string, string, string?, CancellationToken)
Overridden to support Umbraco's own data storage requirements
Declaration
public override Task SetTokenAsync(MemberIdentityUser user, string loginProvider, string name, string? value, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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(MemberIdentityUser, CancellationToken)
Updates the specified user in the user store.
Declaration
public override Task<IdentityResult> UpdateAsync(MemberIdentityUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberIdentityUser | 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. |