Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IUserService

    Defines the UserService, which is an easy access to operations involving IProfile and eventually Users.

    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IUserService : IMembershipUserService, IMembershipMemberService<IUser>, IService

    Methods

    View Source

    AddClientIdAsync(Guid, string)

    Declaration
    Task<UserClientCredentialsOperationStatus> AddClientIdAsync(Guid userKey, string clientId)
    Parameters
    Type Name Description
    Guid userKey
    string clientId
    Returns
    Type Description
    Task<UserClientCredentialsOperationStatus>
    View Source

    AssignUserGroupPermission(int, string, params int[])

    Assigns the same permission set for a single user group to any number of entities

    Declaration
    void AssignUserGroupPermission(int groupId, string permission, params int[] entityIds)
    Parameters
    Type Name Description
    int groupId

    Id of the group

    string permission
    int[] entityIds

    Specify the nodes to replace permissions for

    View Source

    ChangePasswordAsync(Guid, ChangeUserPasswordModel)

    Declaration
    Task<Attempt<PasswordChangedModel, UserOperationStatus>> ChangePasswordAsync(Guid performingUserKey, ChangeUserPasswordModel model)
    Parameters
    Type Name Description
    Guid performingUserKey
    ChangeUserPasswordModel model
    Returns
    Type Description
    Task<Attempt<PasswordChangedModel, UserOperationStatus>>
    View Source

    ClearAvatarAsync(Guid)

    Declaration
    Task<UserOperationStatus> ClearAvatarAsync(Guid userKey)
    Parameters
    Type Name Description
    Guid userKey
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    ClearLoginSession(Guid)

    Removes the session's validity

    Declaration
    void ClearLoginSession(Guid sessionId)
    Parameters
    Type Name Description
    Guid sessionId
    View Source

    ClearLoginSessions(int)

    Removes all valid sessions for the user

    Declaration
    int ClearLoginSessions(int userId)
    Parameters
    Type Name Description
    int userId
    Returns
    Type Description
    int
    View Source

    CreateAsync(Guid, UserCreateModel, bool)

    Creates a user based in a create model and persists it to the database.

    Declaration
    Task<Attempt<UserCreationResult, UserOperationStatus>> CreateAsync(Guid performingUserKey, UserCreateModel model, bool approveUser = false)
    Parameters
    Type Name Description
    Guid performingUserKey

    The key of the user performing the operation.

    UserCreateModel model

    Model to create the user from.

    bool approveUser

    Specifies if the user should be enabled be default. Defaults to false.

    Returns
    Type Description
    Task<Attempt<UserCreationResult, UserOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed UserOperationStatus.

    Remarks

    This creates both the Umbraco user and the identity user.

    View Source

    CreateInitialPasswordAsync(Guid, string, string)

    Declaration
    Task<Attempt<PasswordChangedModel, UserOperationStatus>> CreateInitialPasswordAsync(Guid userKey, string token, string password)
    Parameters
    Type Name Description
    Guid userKey
    string token
    string password
    Returns
    Type Description
    Task<Attempt<PasswordChangedModel, UserOperationStatus>>
    View Source

    CreateLoginSession(int, string)

    Creates a database entry for starting a new login session for a user

    Declaration
    Guid CreateLoginSession(int userId, string requestingIpAddress)
    Parameters
    Type Name Description
    int userId
    string requestingIpAddress
    Returns
    Type Description
    Guid
    View Source

    Delete(IUser, bool)

    Deletes or disables a User

    Declaration
    void Delete(IUser user, bool deletePermanently)
    Parameters
    Type Name Description
    IUser user

    IUser to delete

    bool deletePermanently

    True to permanently delete the user, False to disable the user

    View Source

    DeleteAsync(Guid, ISet<Guid>)

    Declaration
    Task<UserOperationStatus> DeleteAsync(Guid performingUserKey, ISet<Guid> keys)
    Parameters
    Type Name Description
    Guid performingUserKey
    ISet<Guid> keys
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    DeleteAsync(Guid, Guid)

    Declaration
    Task<UserOperationStatus> DeleteAsync(Guid performingUserKey, Guid key)
    Parameters
    Type Name Description
    Guid performingUserKey
    Guid key
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    DeleteSectionFromAllUserGroups(string)

    Removes a specific section from all user groups

    Declaration
    void DeleteSectionFromAllUserGroups(string sectionAlias)
    Parameters
    Type Name Description
    string sectionAlias

    Alias of the section to remove

    Remarks

    This is useful when an entire section is removed from config

    View Source

    DisableAsync(Guid, ISet<Guid>)

    Declaration
    Task<UserOperationStatus> DisableAsync(Guid performingUserKey, ISet<Guid> keys)
    Parameters
    Type Name Description
    Guid performingUserKey
    ISet<Guid> keys
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    EnableAsync(Guid, ISet<Guid>)

    Declaration
    Task<UserOperationStatus> EnableAsync(Guid performingUserKey, ISet<Guid> keys)
    Parameters
    Type Name Description
    Guid performingUserKey
    ISet<Guid> keys
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    FilterAsync(Guid, UserFilter, int, int, UserOrder, Direction)

    Declaration
    Task<Attempt<PagedModel<IUser>, UserOperationStatus>> FilterAsync(Guid userKey, UserFilter filter, int skip = 0, int take = 100, UserOrder orderBy = UserOrder.UserName, Direction orderDirection = Direction.Ascending)
    Parameters
    Type Name Description
    Guid userKey
    UserFilter filter
    int skip
    int take
    UserOrder orderBy
    Direction orderDirection
    Returns
    Type Description
    Task<Attempt<PagedModel<IUser>, UserOperationStatus>>
    View Source

    FindByClientIdAsync(string)

    Declaration
    Task<IUser?> FindByClientIdAsync(string clientId)
    Parameters
    Type Name Description
    string clientId
    Returns
    Type Description
    Task<IUser>
    View Source

    GetAll(long, int, out long, string, Direction, UserState[]?, string[]?, string?)

    Get paged users

    Declaration
    IEnumerable<IUser> GetAll(long pageIndex, int pageSize, out long totalRecords, string orderBy, Direction orderDirection, UserState[]? userState = null, string[]? userGroups = null, string? filter = null)
    Parameters
    Type Name Description
    long pageIndex
    int pageSize
    long totalRecords
    string orderBy
    Direction orderDirection
    UserState[] userState
    string[] userGroups

    A filter to only include user that belong to these user groups

    string filter
    Returns
    Type Description
    IEnumerable<IUser>
    View Source

    GetAll(long, int, out long, string, Direction, UserState[]?, string[]?, string[]?, IQuery<IUser>?)

    Get paged users

    Declaration
    IEnumerable<IUser> GetAll(long pageIndex, int pageSize, out long totalRecords, string orderBy, Direction orderDirection, UserState[]? userState = null, string[]? includeUserGroups = null, string[]? excludeUserGroups = null, IQuery<IUser>? filter = null)
    Parameters
    Type Name Description
    long pageIndex
    int pageSize
    long totalRecords
    string orderBy
    Direction orderDirection
    UserState[] userState
    string[] includeUserGroups

    A filter to only include user that belong to these user groups

    string[] excludeUserGroups

    A filter to only include users that do not belong to these user groups

    IQuery<IUser> filter
    Returns
    Type Description
    IEnumerable<IUser>
    View Source

    GetAllAsync(Guid, int, int)

    Gets all users that the requesting user is allowed to see.

    Declaration
    Task<Attempt<PagedModel<IUser>?, UserOperationStatus>> GetAllAsync(Guid performingUserKey, int skip, int take)
    Parameters
    Type Name Description
    Guid performingUserKey

    The Key of the user requesting the users.

    int skip

    Amount to skip.

    int take

    Amount to take.

    Returns
    Type Description
    Task<Attempt<PagedModel<IUser>, UserOperationStatus>>

    All users that the user is allowed to see.

    View Source

    GetAllInGroup(int?)

    Gets a list of IUser objects associated with a given group

    Declaration
    IEnumerable<IUser> GetAllInGroup(int? groupId)
    Parameters
    Type Name Description
    int? groupId

    Id of group

    Returns
    Type Description
    IEnumerable<IUser>

    System.Collections.Generic.IEnumerable<T>

    View Source

    GetAllNotInGroup(int)

    Gets a list of IUser objects not associated with a given group

    Declaration
    IEnumerable<IUser> GetAllNotInGroup(int groupId)
    Parameters
    Type Name Description
    int groupId

    Id of group

    Returns
    Type Description
    IEnumerable<IUser>

    System.Collections.Generic.IEnumerable<T>

    View Source

    GetAsync(IEnumerable<Guid>)

    Declaration
    Task<IEnumerable<IUser>> GetAsync(IEnumerable<Guid> keys)
    Parameters
    Type Name Description
    IEnumerable<Guid> keys
    Returns
    Type Description
    Task<IEnumerable<IUser>>
    View Source

    GetAsync(Guid)

    Get a user by its key.

    Declaration
    Task<IUser?> GetAsync(Guid key)
    Parameters
    Type Name Description
    Guid key

    The GUID key of the user.

    Returns
    Type Description
    Task<IUser>

    The found user, or null if nothing was found.

    View Source

    GetClientIdsAsync(Guid)

    Declaration
    Task<IEnumerable<string>> GetClientIdsAsync(Guid userKey)
    Parameters
    Type Name Description
    Guid userKey
    Returns
    Type Description
    Task<IEnumerable<string>>
    View Source

    GetDocumentPermissionsAsync(Guid, IEnumerable<Guid>)

    Get explicitly assigned media permissions for a user and node keys.

    Declaration
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>> GetDocumentPermissionsAsync(Guid userKey, IEnumerable<Guid> contentKeys)
    Parameters
    Type Name Description
    Guid userKey

    Key of user to retrieve permissions for.

    IEnumerable<Guid> contentKeys

    The keys of the content to get permissions for.

    Returns
    Type Description
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed UserOperationStatus, and an enumerable of permissions.

    View Source

    GetLinkedLoginsAsync(Guid)

    Declaration
    Task<Attempt<ICollection<IIdentityUserLogin>, UserOperationStatus>> GetLinkedLoginsAsync(Guid userKey)
    Parameters
    Type Name Description
    Guid userKey
    Returns
    Type Description
    Task<Attempt<ICollection<IIdentityUserLogin>, UserOperationStatus>>
    View Source

    GetMediaPermissionsAsync(Guid, IEnumerable<Guid>)

    Get explicitly assigned content permissions for a user and node keys.

    Declaration
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>> GetMediaPermissionsAsync(Guid userKey, IEnumerable<Guid> mediaKeys)
    Parameters
    Type Name Description
    Guid userKey

    Key of user to retrieve permissions for.

    IEnumerable<Guid> mediaKeys

    The keys of the media to get permissions for.

    Returns
    Type Description
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed UserOperationStatus, and an enumerable of permissions.

    View Source

    GetPermissions(IUser?, params int[])

    Get explicitly assigned permissions for a user and optional node ids

    Declaration
    EntityPermissionCollection GetPermissions(IUser? user, params int[] nodeIds)
    Parameters
    Type Name Description
    IUser user

    User to retrieve permissions for

    int[] nodeIds

    Specifying nothing will return all user permissions for all nodes that have explicit permissions defined

    Returns
    Type Description
    EntityPermissionCollection

    An enumerable list of EntityPermission

    Remarks

    If no permissions are found for a particular entity then the user's default permissions will be applied

    View Source

    GetPermissions(IUserGroup?[], bool, params int[])

    Get explicitly assigned permissions for groups and optional node Ids

    Declaration
    EntityPermissionCollection GetPermissions(IUserGroup?[] groups, bool fallbackToDefaultPermissions, params int[] nodeIds)
    Parameters
    Type Name Description
    IUserGroup[] groups
    bool fallbackToDefaultPermissions

    Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set

    int[] nodeIds

    Specifying nothing will return all permissions for all nodes

    Returns
    Type Description
    EntityPermissionCollection

    An enumerable list of EntityPermission

    View Source

    GetPermissionsAsync(Guid, params Guid[])

    Get explicitly assigned permissions for a user and node keys.

    Declaration
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>> GetPermissionsAsync(Guid userKey, params Guid[] nodeKeys)
    Parameters
    Type Name Description
    Guid userKey

    Key of user to retrieve permissions for.

    Guid[] nodeKeys

    The keys of the nodes to get permissions for.

    Returns
    Type Description
    Task<Attempt<IEnumerable<NodePermissions>, UserOperationStatus>>

    An enumerable list of NodePermissions.

    View Source

    GetPermissionsForPath(IUser?, string?)

    Gets the implicit/inherited permissions for the user for the given path

    Declaration
    EntityPermissionSet GetPermissionsForPath(IUser? user, string? path)
    Parameters
    Type Name Description
    IUser user

    User to check permissions for

    string path

    Path to check permissions for

    Returns
    Type Description
    EntityPermissionSet
    View Source

    GetPermissionsForPath(IUserGroup[], string, bool)

    Gets the permissions for the provided groups and path

    Declaration
    EntityPermissionSet GetPermissionsForPath(IUserGroup[] groups, string path, bool fallbackToDefaultPermissions = false)
    Parameters
    Type Name Description
    IUserGroup[] groups
    string path

    Path to check permissions for

    bool fallbackToDefaultPermissions

    Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set

    Returns
    Type Description
    EntityPermissionSet
    View Source

    GetProfileById(int)

    Gets an IProfile by User Id.

    Declaration
    IProfile? GetProfileById(int id)
    Parameters
    Type Name Description
    int id

    Id of the User to retrieve

    Returns
    Type Description
    IProfile

    IProfile

    View Source

    GetProfileByUserName(string)

    Gets a profile by username

    Declaration
    IProfile? GetProfileByUserName(string username)
    Parameters
    Type Name Description
    string username

    Username

    Returns
    Type Description
    IProfile

    IProfile

    View Source

    GetUserById(int)

    Gets a user by Id

    Declaration
    IUser? GetUserById(int id)
    Parameters
    Type Name Description
    int id

    Id of the user to retrieve

    Returns
    Type Description
    IUser

    IUser

    View Source

    GetUserStates()

    This is basically facets of UserStates key = state, value = count

    Declaration
    IDictionary<UserState, int> GetUserStates()
    Returns
    Type Description
    IDictionary<UserState, int>
    View Source

    GetUsersById(params int[]?)

    Gets a users by Id

    Declaration
    IEnumerable<IUser> GetUsersById(params int[]? ids)
    Parameters
    Type Name Description
    int[] ids

    Ids of the users to retrieve

    Returns
    Type Description
    IEnumerable<IUser>

    IUser

    View Source

    InviteAsync(Guid, UserInviteModel)

    Declaration
    Task<Attempt<UserInvitationResult, UserOperationStatus>> InviteAsync(Guid performingUserKey, UserInviteModel model)
    Parameters
    Type Name Description
    Guid performingUserKey
    UserInviteModel model
    Returns
    Type Description
    Task<Attempt<UserInvitationResult, UserOperationStatus>>
    View Source

    RemoveClientIdAsync(Guid, string)

    Declaration
    Task<bool> RemoveClientIdAsync(Guid userKey, string clientId)
    Parameters
    Type Name Description
    Guid userKey
    string clientId
    Returns
    Type Description
    Task<bool>
    View Source

    ReplaceUserGroupPermissions(int, ISet<string>, params int[])

    Replaces the same permission set for a single group to any number of entities

    Declaration
    void ReplaceUserGroupPermissions(int groupId, ISet<string> permissions, params int[] entityIds)
    Parameters
    Type Name Description
    int groupId

    Id of the group

    ISet<string> permissions

    Permissions as enumerable list of char, if no permissions are specified then all permissions for this node are removed for this group

    int[] entityIds

    Specify the nodes to replace permissions for. If nothing is specified all permissions are removed.

    Remarks

    If no 'entityIds' are specified all permissions will be removed for the specified group.

    View Source

    ResendInvitationAsync(Guid, UserResendInviteModel)

    Declaration
    Task<Attempt<UserInvitationResult, UserOperationStatus>> ResendInvitationAsync(Guid performingUserKey, UserResendInviteModel model)
    Parameters
    Type Name Description
    Guid performingUserKey
    UserResendInviteModel model
    Returns
    Type Description
    Task<Attempt<UserInvitationResult, UserOperationStatus>>
    View Source

    ResetPasswordAsync(Guid, Guid)

    Declaration
    Task<Attempt<PasswordChangedModel, UserOperationStatus>> ResetPasswordAsync(Guid performingUserKey, Guid userKey)
    Parameters
    Type Name Description
    Guid performingUserKey
    Guid userKey
    Returns
    Type Description
    Task<Attempt<PasswordChangedModel, UserOperationStatus>>
    View Source

    ResetPasswordAsync(Guid, string, string)

    Changes the user's password.

    Declaration
    Task<Attempt<PasswordChangedModel, UserOperationStatus>> ResetPasswordAsync(Guid userKey, string token, string password)
    Parameters
    Type Name Description
    Guid userKey

    The unique key of the user.

    string token

    The reset password token.

    string password

    The new password of the user.

    Returns
    Type Description
    Task<Attempt<PasswordChangedModel, UserOperationStatus>>
    View Source

    SendResetPasswordEmailAsync(string)

    Sends an email with a link to reset user's password.

    Declaration
    Task<Attempt<UserOperationStatus>> SendResetPasswordEmailAsync(string userEmail)
    Parameters
    Type Name Description
    string userEmail

    The email address of the user.

    Returns
    Type Description
    Task<Attempt<UserOperationStatus>>
    View Source

    SetAvatarAsync(Guid, Guid)

    Declaration
    Task<UserOperationStatus> SetAvatarAsync(Guid userKey, Guid temporaryFileKey)
    Parameters
    Type Name Description
    Guid userKey
    Guid temporaryFileKey
    Returns
    Type Description
    Task<UserOperationStatus>
    View Source

    UnlockAsync(Guid, params Guid[])

    Declaration
    Task<Attempt<UserUnlockResult, UserOperationStatus>> UnlockAsync(Guid performingUserKey, params Guid[] keys)
    Parameters
    Type Name Description
    Guid performingUserKey
    Guid[] keys
    Returns
    Type Description
    Task<Attempt<UserUnlockResult, UserOperationStatus>>
    View Source

    UpdateAsync(Guid, UserUpdateModel)

    Declaration
    Task<Attempt<IUser?, UserOperationStatus>> UpdateAsync(Guid performingUserKey, UserUpdateModel model)
    Parameters
    Type Name Description
    Guid performingUserKey
    UserUpdateModel model
    Returns
    Type Description
    Task<Attempt<IUser, UserOperationStatus>>
    View Source

    ValidateLoginSession(int, Guid)

    Validates that a user login session is valid/current and hasn't been closed

    Declaration
    bool ValidateLoginSession(int userId, Guid sessionId)
    Parameters
    Type Name Description
    int userId
    Guid sessionId
    Returns
    Type Description
    bool
    View Source

    VerifyInviteAsync(Guid, string)

    Declaration
    Task<Attempt<UserOperationStatus>> VerifyInviteAsync(Guid userKey, string token)
    Parameters
    Type Name Description
    Guid userKey
    string token
    Returns
    Type Description
    Task<Attempt<UserOperationStatus>>
    View Source

    VerifyPasswordResetAsync(Guid, string)

    Verifies the reset code sent from the reset password mail for a given user.

    Declaration
    Task<Attempt<UserOperationStatus>> VerifyPasswordResetAsync(Guid userKey, string token)
    Parameters
    Type Name Description
    Guid userKey

    The unique key of the user.

    string token

    The reset password token.

    Returns
    Type Description
    Task<Attempt<UserOperationStatus>>
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX