Core\User\User (Component\Security)
Symfony\Component\Security\Core\User\User
class User implements AdvancedUserInterface
User is the user implementation used by the in-memory user provider.
This should not be used for anything else.
Methods
__construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true) | ||
__toString() | ||
Role[] | 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. |
Details
public __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
public __toString()
public Role[] 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.
public 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.
public 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.
public string getUsername()
Returns the username used to authenticate the user.
public 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.
public bool isAccountNonLocked()
Checks whether the user is locked.
Internally, if this method returns false, the authentication system will throw a LockedException and prevent login.
public 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.
public bool isEnabled()
Checks whether the user is enabled.
Internally, if this method returns false, the authentication system will throw a DisabledException and prevent login.
public 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.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/Security/Core/User/User.html