class User implements UserInterface, EquatableInterface, AdvancedUserInterface

User is the user implementation used by the in-memory user provider.

This should not be used for anything else.

Methods

__construct(string|null $username, string|null $password, array $roles = array(), bool $enabled = true, bool $userNonExpired = true, bool $credentialsNonExpired = true, bool $userNonLocked = true)

No description

__toString()

No description

(Role|string)[]
getRoles()

Returns the roles granted to the user.

string
getPassword()

Returns the password used to authenticate the user.

string|null
getSalt()

Returns the salt that was originally used to encode the password.

string
getUsername()

Returns the username used to authenticate the user.

bool
isAccountNonExpired()

Checks whether the user's account has expired.

bool
isAccountNonLocked()

Checks whether the user is locked.

bool
isCredentialsNonExpired()

Checks whether the user's credentials (password) has expired.

bool
isEnabled()

Checks whether the user is enabled.

eraseCredentials()

Removes sensitive data from the user.

bool
isEqualTo(UserInterface $user)

The equality comparison should neither be done by referential equality nor by comparing identities (i.e. getId() === getId()).

Details

at line 31
__construct(string|null $username, string|null $password, array $roles = array(), bool $enabled = true, bool $userNonExpired = true, bool $credentialsNonExpired = true, bool $userNonLocked = true)

Parameters

string|null $username
string|null $password
array $roles
bool $enabled
bool $userNonExpired
bool $credentialsNonExpired
bool $userNonLocked

at line 46
__toString()

at line 54
(Role|string)[] getRoles()

Returns the roles granted to the user.

public function getRoles() { return array('ROLE_USER'); }

Alternatively, the roles might be stored on a roles property, and populated in any number of different ways when the user object is created.

Return Value

(Role|string)[] The user roles

at line 62
string getPassword()

Returns the password used to authenticate the user.

This should be the encoded password. On authentication, a plain-text password will be salted, encoded, and then compared to this value.

Return Value

string The password

at line 70
string|null getSalt()

Returns the salt that was originally used to encode the password.

This can return null if the password was not encoded using a salt.

Return Value

string|null The salt

at line 77
string getUsername()

Returns the username used to authenticate the user.

Return Value

string The username

at line 85
bool isAccountNonExpired()

Checks whether the user's account has expired.

Internally, if this method returns false, the authentication system will throw an AccountExpiredException and prevent login.

Return Value

bool true if the user's account is non expired, false otherwise

at line 93
bool isAccountNonLocked()

Checks whether the user is locked.

Internally, if this method returns false, the authentication system will throw a LockedException and prevent login.

Return Value

bool true if the user is not locked, false otherwise

at line 101
bool isCredentialsNonExpired()

Checks whether the user's credentials (password) has expired.

Internally, if this method returns false, the authentication system will throw a CredentialsExpiredException and prevent login.

Return Value

bool true if the user's credentials are non expired, false otherwise

at line 109
bool isEnabled()

Checks whether the user is enabled.

Internally, if this method returns false, the authentication system will throw a DisabledException and prevent login.

Return Value

bool true if the user is enabled, false otherwise

at line 117
eraseCredentials()

Removes sensitive data from the user.

This is important if, at any given point, sensitive information like the plain-text password is stored on this object.

at line 124
bool isEqualTo(UserInterface $user)

The equality comparison should neither be done by referential equality nor by comparing identities (i.e. getId() === getId()).

However, you do not need to compare every attribute, but only those that are relevant for assessing whether re-authentication is required.

Parameters

UserInterface $user

Return Value

bool