Search Results for

    Show / Hide Table of Contents
    View Source

    Class UmbracoUserManager<TUser, TPasswordConfig>

    Abstract class for Umbraco User Managers for back office users or front-end members

    Inheritance
    object
    UserManager<TUser>
    Namespace: Umbraco.Cms.Core.Security
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public abstract class UmbracoUserManager<TUser, TPasswordConfig> : UserManager<TUser> where TUser : UmbracoIdentityUser where TPasswordConfig : class, IPasswordConfiguration, new()
    Type Parameters
    Name Description
    TUser

    The type of user

    TPasswordConfig

    The type password config

    Constructors

    View Source

    UmbracoUserManager(IIpResolver, IUserStore<TUser>, IOptions<IdentityOptions>, IPasswordHasher<TUser>, IEnumerable<IUserValidator<TUser>>, IEnumerable<IPasswordValidator<TUser>>, IdentityErrorDescriber, IServiceProvider, ILogger<UserManager<TUser>>, IOptions<TPasswordConfig>)

    Initializes a new instance of the UmbracoUserManager<TUser, TPasswordConfig> class.

    Declaration
    public UmbracoUserManager(IIpResolver ipResolver, IUserStore<TUser> store, IOptions<IdentityOptions> optionsAccessor, IPasswordHasher<TUser> passwordHasher, IEnumerable<IUserValidator<TUser>> userValidators, IEnumerable<IPasswordValidator<TUser>> passwordValidators, IdentityErrorDescriber errors, IServiceProvider services, ILogger<UserManager<TUser>> logger, IOptions<TPasswordConfig> passwordConfiguration)
    Parameters
    Type Name Description
    IIpResolver ipResolver
    IUserStore<TUser> store
    IOptions<IdentityOptions> optionsAccessor
    IPasswordHasher<TUser> passwordHasher
    IEnumerable<IUserValidator<TUser>> userValidators
    IEnumerable<IPasswordValidator<TUser>> passwordValidators
    IdentityErrorDescriber errors
    IServiceProvider services
    ILogger<UserManager<TUser>> logger
    IOptions<TPasswordConfig> passwordConfiguration

    Properties

    View Source

    IpResolver

    Gets the IP resolver

    Declaration
    public IIpResolver IpResolver { get; }
    Property Value
    Type Description
    IIpResolver
    View Source

    PasswordConfiguration

    Gets the password configuration

    Declaration
    public IPasswordConfiguration PasswordConfiguration { get; }
    Property Value
    Type Description
    IPasswordConfiguration
    View Source

    SupportsQueryableUsers

    Gets a flag indicating whether the backing user store supports returning System.Linq.IQueryable collections of information.

    Declaration
    public override bool SupportsQueryableUsers { get; }
    Property Value
    Type Description
    bool

    true if the backing user store supports returning System.Linq.IQueryable collections of information, otherwise false.

    View Source

    SupportsUserClaim

    Gets a flag indicating whether the backing user store supports user claims.

    Declaration
    public override bool SupportsUserClaim { get; }
    Property Value
    Type Description
    bool

    true if the backing user store supports user claims, otherwise false.

    View Source

    SupportsUserPhoneNumber

    Gets a flag indicating whether the backing user store supports user telephone numbers.

    Declaration
    public override bool SupportsUserPhoneNumber { get; }
    Property Value
    Type Description
    bool

    true if the backing user store supports user telephone numbers, otherwise false.

    View Source

    SupportsUserTwoFactor

    Both users and members supports 2FA

    Declaration
    public override bool SupportsUserTwoFactor { get; }
    Property Value
    Type Description
    bool

    true if the backing user store supports user two factor authentication, otherwise false.

    Methods

    View Source

    AccessFailedAsync(TUser)

    Overrides the Microsoft ASP.NET user management method

    Declaration
    public override Task<IdentityResult> AccessFailedAsync(TUser user)
    Parameters
    Type Name Description
    TUser user

    The user whose failed access count to increment.

    Returns
    Type Description
    Task<IdentityResult>

    The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

    View Source

    ChangePasswordWithResetAsync(string, string, string)

    This is a special method that will reset the password but will raise the Password Changed event instead of the reset event

    Declaration
    public virtual Task<IdentityResult> ChangePasswordWithResetAsync(string userId, string token, string newPassword)
    Parameters
    Type Name Description
    string userId

    The userId

    string token

    The reset password token

    string newPassword

    The new password to set it to

    Returns
    Type Description
    Task<IdentityResult>

    The Microsoft.AspNetCore.Identity.IdentityResult

    Remarks

    We use this because in the back office the only way an admin can change another user's password without first knowing their password is to generate a token and reset it, however, when we do this we want to track a password change, not a password reset

    View Source

    CheckPasswordAsync(TUser, string?)

    Returns a flag indicating whether the given password is valid for the specified user.

    Declaration
    public override Task<bool> CheckPasswordAsync(TUser user, string? password)
    Parameters
    Type Name Description
    TUser user

    The user whose password should be validated.

    string password

    The password to validate

    Returns
    Type Description
    Task<bool>

    The System.Threading.Tasks.Task that represents the asynchronous operation, containing true if the specified password matches the one store for the user, otherwise false.

    View Source

    GeneratePassword()

    Helper method to generate a password for a user based on the current password validator

    Declaration
    public string GeneratePassword()
    Returns
    Type Description
    string

    The generated password

    View Source

    GetValidTwoFactorProvidersAsync(TUser)

    Declaration
    public virtual Task<IList<string>> GetValidTwoFactorProvidersAsync(TUser user)
    Parameters
    Type Name Description
    TUser user
    Returns
    Type Description
    Task<IList<string>>
    View Source

    IsLockedOutAsync(TUser)

    Override to check the user approval value as well as the user lock out date, by default this only checks the user's locked out date

    Declaration
    public override Task<bool> IsLockedOutAsync(TUser user)
    Parameters
    Type Name Description
    TUser user

    The user

    Returns
    Type Description
    Task<bool>

    True if the user is locked out, else false

    Remarks

    In the ASP.NET Identity world, there is only one value for being locked out, in Umbraco we have 2 so when checking this for Umbraco we need to check both values

    View Source

    ResetAccessFailedCountAsync(TUser)

    Resets the access failed count for the specified user.

    Declaration
    public override Task<IdentityResult> ResetAccessFailedCountAsync(TUser user)
    Parameters
    Type Name Description
    TUser user

    The user whose failed access count should be reset.

    Returns
    Type Description
    Task<IdentityResult>

    The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

    View Source

    SetLockoutEndDateAsync(TUser, DateTimeOffset?)

    Locks out a user until the specified end date has passed. Setting a end date in the past immediately unlocks a user.

    Declaration
    public override Task<IdentityResult> SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd)
    Parameters
    Type Name Description
    TUser user

    The user whose lockout date should be set.

    DateTimeOffset? lockoutEnd

    The System.DateTimeOffset after which the user's lockout should end.

    Returns
    Type Description
    Task<IdentityResult>

    The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

    View Source

    ValidateCredentialsAsync(string, string)

    Declaration
    public Task<bool> ValidateCredentialsAsync(string username, string password)
    Parameters
    Type Name Description
    string username
    string password
    Returns
    Type Description
    Task<bool>
    View Source

    ValidatePasswordAsync(string?)

    Used to validate the password without an identity user Validation code is based on the default ValidatePasswordAsync code Should return Microsoft.AspNetCore.Identity.IdentityResult.Success if validation is successful

    Declaration
    public Task<IdentityResult> ValidatePasswordAsync(string? password)
    Parameters
    Type Name Description
    string password

    The password.

    Returns
    Type Description
    Task<IdentityResult>

    A Microsoft.AspNetCore.Identity.IdentityResult representing whether validation was successful.

    View Source

    ValidateSessionIdAsync(string?, string?)

    Used to validate a user's session

    Declaration
    public virtual Task<bool> ValidateSessionIdAsync(string? userId, string? sessionId)
    Parameters
    Type Name Description
    string userId

    The user id

    string sessionId

    The session id

    Returns
    Type Description
    Task<bool>

    True if the session is valid, else false

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX