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 SourceAssignUserGroupPermission(Int32, String, Int32[])
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 |
---|---|---|
System.Int32 | groupId | Id of the group |
System.String | permission | |
System.Int32[] | entityIds | Specify the nodes to replace permissions for |
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>> |
ClearAvatarAsync(Guid)
Declaration
Task<UserOperationStatus> ClearAvatarAsync(Guid userKey)
Parameters
Type | Name | Description |
---|---|---|
Guid | userKey |
Returns
Type | Description |
---|---|
Task<UserOperationStatus> |
ClearLoginSession(Guid)
Removes the session's validity
Declaration
void ClearLoginSession(Guid sessionId)
Parameters
Type | Name | Description |
---|---|---|
Guid | sessionId |
ClearLoginSessions(Int32)
Removes all valid sessions for the user
Declaration
int ClearLoginSessions(int userId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId |
Returns
Type | Description |
---|---|
System.Int32 |
CreateAsync(Guid, UserCreateModel, Boolean)
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. |
System.Boolean | 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.
CreateInitialPasswordAsync(Guid, String, String)
Declaration
Task<Attempt<PasswordChangedModel, UserOperationStatus>> CreateInitialPasswordAsync(Guid userKey, string token, string password)
Parameters
Type | Name | Description |
---|---|---|
Guid | userKey | |
System.String | token | |
System.String | password |
Returns
Type | Description |
---|---|
Task<Attempt<PasswordChangedModel, UserOperationStatus>> |
CreateLoginSession(Int32, 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 |
---|---|---|
System.Int32 | userId | |
System.String | requestingIpAddress |
Returns
Type | Description |
---|---|
Guid |
Delete(IUser, Boolean)
Deletes or disables a User
Declaration
void Delete(IUser user, bool deletePermanently)
Parameters
Type | Name | Description |
---|---|---|
IUser | user | IUser to delete |
System.Boolean | deletePermanently |
|
DeleteAsync(Guid, Guid)
Declaration
virtual Task<UserOperationStatus> DeleteAsync(Guid performingUserKey, Guid key)
Parameters
Type | Name | Description |
---|---|---|
Guid | performingUserKey | |
Guid | key |
Returns
Type | Description |
---|---|
Task<UserOperationStatus> |
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> |
DeleteSectionFromAllUserGroups(String)
Removes a specific section from all user groups
Declaration
void DeleteSectionFromAllUserGroups(string sectionAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | sectionAlias | Alias of the section to remove |
Remarks
This is useful when an entire section is removed from config
DeleteUserGroup(IUserGroup)
Deletes a UserGroup
Declaration
void DeleteUserGroup(IUserGroup userGroup)
Parameters
Type | Name | Description |
---|---|---|
IUserGroup | userGroup | UserGroup to delete |
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> |
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> |
FilterAsync(Guid, UserFilter, Int32, Int32, UserOrder, Direction)
Declaration
virtual 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 | |
System.Int32 | skip | |
System.Int32 | take | |
UserOrder | orderBy | |
Direction | orderDirection |
Returns
Type | Description |
---|---|
Task<Attempt<PagedModel<IUser>, UserOperationStatus>> |
GetAll(Int64, Int32, out Int64, 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 |
---|---|---|
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
System.String | orderBy | |
Direction | orderDirection | |
UserState[] | userState | |
System.String[] | userGroups | A filter to only include user that belong to these user groups |
System.String | filter |
Returns
Type | Description |
---|---|
IEnumerable<IUser> |
GetAll(Int64, Int32, out Int64, 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 |
---|---|---|
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
System.String | orderBy | |
Direction | orderDirection | |
UserState[] | userState | |
System.String[] | includeUserGroups | A filter to only include user that belong to these user groups |
System.String[] | excludeUserGroups | A filter to only include users that do not belong to these user groups |
IQuery<IUser> | filter |
Returns
Type | Description |
---|---|
IEnumerable<IUser> |
GetAllAsync(Guid, Int32, Int32)
Gets all users that the requesting user is allowed to see.
Declaration
virtual 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. |
System.Int32 | skip | Amount to skip. |
System.Int32 | take | Amount to take. |
Returns
Type | Description |
---|---|
Task<Attempt<PagedModel<IUser>, UserOperationStatus>> | All users that the user is allowed to see. |
GetAllInGroup(Nullable<Int32>)
Gets a list of IUser objects associated with a given group
Declaration
IEnumerable<IUser> GetAllInGroup(int? groupId)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | groupId | Id of group |
Returns
Type | Description |
---|---|
IEnumerable<IUser> |
GetAllNotInGroup(Int32)
Gets a list of IUser objects not associated with a given group
Declaration
IEnumerable<IUser> GetAllNotInGroup(int groupId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | groupId | Id of group |
Returns
Type | Description |
---|---|
IEnumerable<IUser> |
GetAllUserGroups(Int32[])
Gets all UserGroups or those specified as parameters
Declaration
IEnumerable<IUserGroup> GetAllUserGroups(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | Optional Ids of UserGroups to retrieve |
Returns
Type | Description |
---|---|
IEnumerable<IUserGroup> | An enumerable list of IUserGroup |
GetAsync(Guid)
Get a user by its key.
Declaration
virtual 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. |
GetAsync(IEnumerable<Guid>)
Declaration
virtual Task<IEnumerable<IUser>> GetAsync(IEnumerable<Guid> keys)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Guid> | keys |
Returns
Type | Description |
---|---|
Task<IEnumerable<IUser>> |
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. |
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>> |
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. |
GetPermissions(IUser, Int32[])
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 |
System.Int32[] | 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
GetPermissions(IUserGroup[], Boolean, Int32[])
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 | |
System.Boolean | fallbackToDefaultPermissions | Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set |
System.Int32[] | nodeIds | Specifying nothing will return all permissions for all nodes |
Returns
Type | Description |
---|---|
EntityPermissionCollection | An enumerable list of EntityPermission |
GetPermissionsAsync(Guid, 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. |
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 |
System.String | path | Path to check permissions for |
Returns
Type | Description |
---|---|
EntityPermissionSet |
GetPermissionsForPath(IUserGroup[], String, Boolean)
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 | |
System.String | path | Path to check permissions for |
System.Boolean | 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 |
GetProfileById(Int32)
Gets an IProfile by User Id.
Declaration
IProfile GetProfileById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the User to retrieve |
Returns
Type | Description |
---|---|
IProfile | IProfile |
GetProfileByUserName(String)
Gets a profile by username
Declaration
IProfile GetProfileByUserName(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username |
Returns
Type | Description |
---|---|
IProfile | IProfile |
GetUserById(Int32)
Gets a user by Id
Declaration
IUser GetUserById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the user to retrieve |
Returns
Type | Description |
---|---|
IUser | IUser |
GetUserGroupByAlias(String)
Gets a UserGroup by its Alias
Declaration
IUserGroup GetUserGroupByAlias(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the UserGroup to retrieve |
Returns
Type | Description |
---|---|
IUserGroup | IUserGroup |
GetUserGroupById(Int32)
Gets a UserGroup by its Id
Declaration
IUserGroup GetUserGroupById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the UserGroup to retrieve |
Returns
Type | Description |
---|---|
IUserGroup | IUserGroup |
GetUserGroupsByAlias(String[])
Gets a UserGroup by its Alias
Declaration
IEnumerable<IUserGroup> GetUserGroupsByAlias(params string[] alias)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | alias | Alias of the UserGroup to retrieve |
Returns
Type | Description |
---|---|
IEnumerable<IUserGroup> | IUserGroup |
GetUsersById(Int32[])
Gets a users by Id
Declaration
IEnumerable<IUser> GetUsersById(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | Ids of the users to retrieve |
Returns
Type | Description |
---|---|
IEnumerable<IUser> | IUser |
GetUserStates()
This is basically facets of UserStates key = state, value = count
Declaration
IDictionary<UserState, int> GetUserStates()
Returns
Type | Description |
---|---|
IDictionary<UserState, System.Int32> |
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>> |
ReplaceUserGroupPermissions(Int32, ISet<String>, Int32[])
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 |
---|---|---|
System.Int32 | groupId | Id of the group |
ISet<System.String> | permissions | Permissions as enumerable list of System.Char, if no permissions are specified then all permissions for this node are removed for this group |
System.Int32[] | 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.
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>> |
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>> |
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. |
System.String | token | The reset password token. |
System.String | password | The new password of the user. |
Returns
Type | Description |
---|---|
Task<Attempt<PasswordChangedModel, UserOperationStatus>> |
Save(IUserGroup, Int32[])
Saves a UserGroup
Declaration
void Save(IUserGroup userGroup, int[] userIds = null)
Parameters
Type | Name | Description |
---|---|---|
IUserGroup | userGroup | UserGroup to save |
System.Int32[] | userIds | If null than no changes are made to the users who are assigned to this group, however if a value is passed in than all users will be removed from this group and only these users will be added |
SendResetPasswordEmailAsync(String)
Sends an email with a link to reset user's password.
Declaration
Task<Attempt<UserOperationStatus>> SendResetPasswordEmailAsync(string userEmail)
Parameters
Type | Name | Description |
---|---|---|
System.String | userEmail | The email address of the user. |
Returns
Type | Description |
---|---|
Task<Attempt<UserOperationStatus>> |
SetAvatarAsync(Guid, Guid)
Declaration
Task<UserOperationStatus> SetAvatarAsync(Guid userKey, Guid temporaryFileKey)
Parameters
Type | Name | Description |
---|---|---|
Guid | userKey | |
Guid | temporaryFileKey |
Returns
Type | Description |
---|---|
Task<UserOperationStatus> |
UnlockAsync(Guid, 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>> |
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>> |
ValidateLoginSession(Int32, 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 |
---|---|---|
System.Int32 | userId | |
Guid | sessionId |
Returns
Type | Description |
---|---|
System.Boolean |
VerifyInviteAsync(Guid, String)
Declaration
Task<Attempt<UserOperationStatus>> VerifyInviteAsync(Guid userKey, string token)
Parameters
Type | Name | Description |
---|---|---|
Guid | userKey | |
System.String | token |
Returns
Type | Description |
---|---|
Task<Attempt<UserOperationStatus>> |
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. |
System.String | token | The reset password token. |
Returns
Type | Description |
---|---|
Task<Attempt<UserOperationStatus>> |