UserService
class UserService (View source)
A service for managing users
Properties
protected string | $defaultAuthenticationProviderName | Might be configurable in the future, for now centralising this as a "constant" |
|
protected WorkspaceRepository | $workspaceRepository | ||
protected PublishingService | $publishingService | ||
protected PartyRepository | $partyRepository | ||
protected UserRepository | $userRepository | ||
protected PartyService | $partyService | ||
protected AccountFactory | $accountFactory | ||
protected AccountRepository | $accountRepository | ||
protected PolicyService | $policyService | ||
protected AuthenticationManagerInterface | $authenticationManager | ||
protected PrivilegeManagerInterface | $privilegeManager | ||
protected Context | $securityContext | ||
protected TokenAndProviderFactoryInterface | $tokenAndProviderFactory | ||
protected HashService | $hashService | ||
protected SessionManager | $sessionManager | ||
protected PersistenceManagerInterface | $persistenceManager | ||
protected Now | $now | ||
protected array | $runtimeUserCache |
Methods
Retrieves a list of all existing users
No description
Retrieves an existing user by the given username
Returns the username of the given user
Returns the currently logged in user, if any
Creates a user based on the given information
Deletes the specified user and all remaining content in his personal workspaces
Updates the given user in the respective repository and potentially executes further actions depending on what has been changed.
Adds the specified role to all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
Removes the specified role from all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
Overrides any assigned roles of the given account and potentially carries out further actions which are needed to properly reflect these changes.
Adds the specified role to the given account and potentially carries out further actions which are needed to properly reflect these changes.
Signals that new roles have been assigned to the given account
Removes the specified role from the given account and potentially carries out further actions which are needed to properly reflect these changes.
Signals that roles have been removed to the given account
Checks if the current user may publish to the given workspace according to one the roles of the user's accounts
Checks if the current user may read the given workspace according to one the roles of the user's accounts
Checks if the current user may manage the given workspace according to one the roles of the user's accounts
Checks if the current user may transfer ownership of the given workspace
No description
Returns the default authentication provider name
Replaces role identifiers not containing a "." into fully qualified role identifiers from the Neos.Neos namespace.
Replaces a role identifier not containing a "." into fully qualified role identifier from the Neos.Neos namespace.
Returns an array with all roles of a user's accounts, including parent roles, the "Everybody" role and the "AuthenticatedUser" role, assuming that the user is logged in.
Creates a personal workspace for the given user's account if it does not exist already.
Removes all personal workspaces of the given user's account if these workspaces exist. Also removes all possibly existing content of these workspaces.
Removes ownership of all workspaces currently owned by the given user
No description
Details
QueryResultInterface
getUsers()
Retrieves a list of all existing users
QueryResultInterface
searchUsers(string $searchTerm)
No description
User|null
getUser(string $username, string $authenticationProviderName = null)
Retrieves an existing user by the given username
string
getUsername(User $user, string $authenticationProviderName = null)
Returns the username of the given user
Technically, this method will look for the user's backend account (or, if authenticationProviderName is specified, for the account matching the given authentication provider) and return the account's identifier.
User
getCurrentUser()
Returns the currently logged in user, if any
User
createUser(string $username, string $password, string $firstName, string $lastName, array $roleIdentifiers = null, string $authenticationProviderName = null)
Creates a user based on the given information
The created user and account are automatically added to their respective repositories and thus be persisted.
User
addUser(string $username, string $password, User $user, array $roleIdentifiers = null, string $authenticationProviderName = null)
Adds a user whose User object has been created elsewhere
This method basically "creates" a user like createUser() would, except that it does not create the User object itself. If you need to create the User object elsewhere, for example in your ActionController, make sure to call this method for registering the new user instead of adding it to the PartyRepository manually.
This method also creates a new user workspace for the given user if no such workspace exist.
void
emitUserCreated(User $user)
Signals that a new user, including a new account has been created.
void
deleteUser(User $user)
Deletes the specified user and all remaining content in his personal workspaces
void
emitUserDeleted(User $user)
Signals that the given user has been deleted.
void
setUserPassword(User $user, string $password)
Sets a new password for the given user
This method will iterate over all accounts owned by the given user and, if the account uses a UsernamePasswordToken, sets a new password accordingly.
void
updateUser(User $user)
Updates the given user in the respective repository and potentially executes further actions depending on what has been changed.
Note: changes to the user's account will not be committed for persistence. Please use addRoleToAccount(), removeRoleFromAccount(), setRolesForAccount() and setUserPassword() for changing account properties.
int
addRoleToUser(User $user, string $roleIdentifier)
Adds the specified role to all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
int
removeRoleFromUser(User $user, string $roleIdentifier)
Removes the specified role from all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
void
emitUserUpdated(User $user)
Signals that the given user data has been updated.
void
setRolesForAccount(Account $account, array $newRoleIdentifiers)
Overrides any assigned roles of the given account and potentially carries out further actions which are needed to properly reflect these changes.
int
addRoleToAccount(Account $account, string $roleIdentifier)
Adds the specified role to the given account and potentially carries out further actions which are needed to properly reflect these changes.
void
emitRolesAdded(Account $account, array $roles)
Signals that new roles have been assigned to the given account
int
removeRoleFromAccount(Account $account, string $roleIdentifier)
Removes the specified role from the given account and potentially carries out further actions which are needed to properly reflect these changes.
void
emitRolesRemoved(Account $account, array $roles)
Signals that roles have been removed to the given account
void
activateUser(User $user)
Reactivates the given user
void
emitUserActivated(User $user)
Signals that the given user has been activated
void
deactivateUser(User $user)
Deactivates the given user
bool
currentUserCanPublishToWorkspace(Workspace $workspace)
Checks if the current user may publish to the given workspace according to one the roles of the user's accounts
In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
bool
currentUserCanReadWorkspace(Workspace $workspace)
Checks if the current user may read the given workspace according to one the roles of the user's accounts
In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
bool
currentUserCanManageWorkspace(Workspace $workspace)
Checks if the current user may manage the given workspace according to one the roles of the user's accounts
In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
bool
currentUserCanTransferOwnershipOfWorkspace(Workspace $workspace)
Checks if the current user may transfer ownership of the given workspace
In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
bool
currentUserIsAdministrator()
No description
string
getDefaultAuthenticationProviderName()
Returns the default authentication provider name
void
emitUserDeactivated(User $user)
Signals that the given user has been activated
protected array
normalizeRoleIdentifiers(array $roleIdentifiers)
Replaces role identifiers not containing a "." into fully qualified role identifiers from the Neos.Neos namespace.
protected string
normalizeRoleIdentifier(string $roleIdentifier)
Replaces a role identifier not containing a "." into fully qualified role identifier from the Neos.Neos namespace.
array
getAllRoles(User $user)
Returns an array with all roles of a user's accounts, including parent roles, the "Everybody" role and the "AuthenticatedUser" role, assuming that the user is logged in.
protected
createPersonalWorkspace(User $user, Account $account)
Creates a personal workspace for the given user's account if it does not exist already.
protected void
deletePersonalWorkspace(string $accountIdentifier)
Removes all personal workspaces of the given user's account if these workspaces exist. Also removes all possibly existing content of these workspaces.
protected void
removeOwnerFromUsersWorkspaces(User $user)
Removes ownership of all workspaces currently owned by the given user
protected AbstractParty|null
findUserForAccount(string $username, string $authenticationProviderName)
No description