class UserCommandController extends CommandController (View source)

The User Command Controller

Properties

protected UserService $userService
protected array $authenticationProviderSettings

Methods

void
listCommand()

List all users

void
showCommand(string $username, string $authenticationProvider = null)

Shows the given user

void
createCommand(string $username, string $password, string $firstName, string $lastName, string $roles = null, string $authenticationProvider = null)

Create a new user

void
deleteCommand(string $username, bool $assumeYes = false, string $authenticationProvider = null)

Delete a user (with globbing)

void
activateCommand(string $username, string $authenticationProvider = null)

Activate a user (with globbing)

void
deactivateCommand(string $username, string $authenticationProvider = null)

Deactivate a user (with globbing)

void
setPasswordCommand(string $username, string $password, string $authenticationProvider = null)

Set a new password for the given user

void
addRoleCommand(string $username, string $role, string $authenticationProvider = null)

Add a role to a user

void
removeRoleCommand(string $username, string $role, string $authenticationProvider = null)

Remove a role from a user

User[]
findUsersByUsernamePattern(string $usernamePattern, string $authenticationProviderName = null)

Find all users the match the given username with globbing support

array
getTableRowForUser(User $user)

Prepares a table row for output with data of the given User

Details

void listCommand()

List all users

This command lists all existing Neos users.

Return Value

void

void showCommand(string $username, string $authenticationProvider = null)

Shows the given user

This command shows some basic details about the given user. If such a user does not exist, this command will exit with a non-zero status code.

The user will be retrieved by looking for a Neos backend account with the given identifier (ie. the username) and then retrieving the user which owns that account. If an authentication provider is specified, this command will look for an account identified by "username" for that specific provider.

Parameters

string $username

The username of the user to show. Usually refers to the account identifier of the user's Neos backend account.

string $authenticationProvider

Name of the authentication provider to use. Example: "Neos.Neos:Backend"

Return Value

void

void createCommand(string $username, string $password, string $firstName, string $lastName, string $roles = null, string $authenticationProvider = null)

Create a new user

This command creates a new user which has access to the backend user interface.

More specifically, this command will create a new user and a new account at the same time. The created account is, by default, a Neos backend account using the the "Neos.Neos:Backend" for authentication. The given username will be used as an account identifier for that new account.

If an authentication provider name is specified, the new account will be created for that provider instead.

Roles for the new user can optionally be specified as a comma separated list. For all roles provided by Neos, the role namespace "Neos.Neos:" can be omitted.

Parameters

string $username

The username of the user to be created, used as an account identifier for the newly created account

string $password

Password of the user to be created

string $firstName

First name of the user to be created

string $lastName

Last name of the user to be created

string $roles

A comma separated list of roles to assign. Examples: "Editor, Acme.Foo:Reviewer"

string $authenticationProvider

Name of the authentication provider to use for the new account. Example: "Neos.Neos:Backend"

Return Value

void

void deleteCommand(string $username, bool $assumeYes = false, string $authenticationProvider = null)

Delete a user (with globbing)

This command deletes an existing Neos user. All content and data directly related to this user, including but not limited to draft workspace contents, will be removed as well.

All accounts owned by the given user will be deleted.

If an authentication provider is specified, this command will look for an account with the given username related to the given provider. Specifying an authentication provider does not mean that only the account for that provider is deleted! If a user was found by the combination of username and authentication provider, all related accounts will be deleted.

Parameters

string $username

The username of the user to be removed (globbing is supported)

bool $assumeYes

Assume "yes" as the answer to the confirmation dialog

string $authenticationProvider

Name of the authentication provider to use. Example: "Neos.Neos:Backend"

Return Value

void

void activateCommand(string $username, string $authenticationProvider = null)

Activate a user (with globbing)

This command reactivates possibly expired accounts for the given user.

If an authentication provider is specified, this command will look for an account with the given username related to the given provider. Still, this command will activate all accounts of a user, once such a user has been found.

Parameters

string $username

The username of the user to be activated (globbing is supported)

string $authenticationProvider

Name of the authentication provider to use for finding the user. Example: "Neos.Neos:Backend"

Return Value

void

void deactivateCommand(string $username, string $authenticationProvider = null)

Deactivate a user (with globbing)

This command deactivates a user by flagging all of its accounts as expired.

If an authentication provider is specified, this command will look for an account with the given username related to the given provider. Still, this command will deactivate all accounts of a user, once such a user has been found.

Parameters

string $username

The username of the user to be deactivated (globbing is supported)

string $authenticationProvider

Name of the authentication provider to use for finding the user. Example: "Neos.Neos:Backend"

Return Value

void

void setPasswordCommand(string $username, string $password, string $authenticationProvider = null)

Set a new password for the given user

This command sets a new password for an existing user. More specifically, all accounts related to the user which are based on a username / password token will receive the new password.

If an authentication provider was specified, the user will be determined by an account identified by "username" related to the given provider.

Parameters

string $username

Username of the user to modify

string $password

The new password

string $authenticationProvider

Name of the authentication provider to use for finding the user. Example: "Neos.Neos:Backend"

Return Value

void

void addRoleCommand(string $username, string $role, string $authenticationProvider = null)

Add a role to a user

This command allows for adding a specific role to an existing user.

Roles can optionally be specified as a comma separated list. For all roles provided by Neos, the role namespace "Neos.Neos:" can be omitted.

If an authentication provider was specified, the user will be determined by an account identified by "username" related to the given provider. However, once a user has been found, the new role will be added to all existing accounts related to that user, regardless of its authentication provider.

Parameters

string $username

The username of the user (globbing is supported)

string $role

Role to be added to the user, for example "Neos.Neos:Administrator" or just "Administrator"

string $authenticationProvider

Name of the authentication provider to use. Example: "Neos.Neos:Backend"

Return Value

void

void removeRoleCommand(string $username, string $role, string $authenticationProvider = null)

Remove a role from a user

This command allows for removal of a specific role from an existing user.

If an authentication provider was specified, the user will be determined by an account identified by "username" related to the given provider. However, once a user has been found, the role will be removed from all existing accounts related to that user, regardless of its authentication provider.

Parameters

string $username

The username of the user (globbing is supported)

string $role

Role to be removed from the user, for example "Neos.Neos:Administrator" or just "Administrator"

string $authenticationProvider

Name of the authentication provider to use. Example: "Neos.Neos:Backend"

Return Value

void

protected User[] findUsersByUsernamePattern(string $usernamePattern, string $authenticationProviderName = null)

Find all users the match the given username with globbing support

Parameters

string $usernamePattern

pattern for the username of the users to find

string $authenticationProviderName

Name of the authentication provider to use

Return Value

User[]

protected array getTableRowForUser(User $user)

Prepares a table row for output with data of the given User

Parameters

User $user

The user

Return Value

array