AdvancedUserInterface
extends
UserInterface
in
Adds extra features to a user class related to account status flags.
This interface can be implemented in place of UserInterface if you'd like the authentication system to consider different account status flags during authentication. If any of the methods in this interface return false, authentication will fail.
If you need to perform custom logic for any of these situations, then you will need to register an exception listener and watch for the specific exception instances thrown in each case. All exceptions are a subclass of AccountStatusException
Tags
Table of Contents
- eraseCredentials() : mixed
- Removes sensitive data from the user.
- getPassword() : string|null
- Returns the password used to authenticate the user.
- getRoles() : array<string|int, \Symfony\Component\Security\Core\Role\Role|string>
- Returns the roles granted to the user.
- getSalt() : string|null
- Returns the salt that was originally used to encode the password.
- getUsername() : string
- Returns the username used to authenticate the user.
- isAccountNonExpired() : bool
- Checks whether the user's account has expired.
- isAccountNonLocked() : bool
- Checks whether the user is locked.
- isCredentialsNonExpired() : bool
- Checks whether the user's credentials (password) has expired.
- isEnabled() : bool
- Checks whether the user is enabled.
Methods
eraseCredentials()
Removes sensitive data from the user.
public
eraseCredentials() : mixed
This is important if, at any given point, sensitive information like the plain-text password is stored on this object.
Return values
mixed —getPassword()
Returns the password used to authenticate the user.
public
getPassword() : string|null
This should be the encoded password. On authentication, a plain-text password will be salted, encoded, and then compared to this value.
Return values
string|null —The encoded password if any
getRoles()
Returns the roles granted to the user.
public
getRoles() : array<string|int, \Symfony\Component\Security\Core\Role\Role|string>
public function getRoles() { return ['ROLE_USER']; }
Alternatively, the roles might be stored in a roles property,
and populated in any number of different ways when the user object
is created.
Return values
array<string|int, \Symfony\Component\Security\Core\Role\Role|string> —The user roles
getSalt()
Returns the salt that was originally used to encode the password.
public
getSalt() : string|null
This can return null if the password was not encoded using a salt.
Return values
string|null —The salt
getUsername()
Returns the username used to authenticate the user.
public
getUsername() : string
Return values
string —The username
isAccountNonExpired()
Checks whether the user's account has expired.
public
isAccountNonExpired() : bool
Internally, if this method returns false, the authentication system will throw an AccountExpiredException and prevent login.
Tags
Return values
bool —true if the user's account is non expired, false otherwise
isAccountNonLocked()
Checks whether the user is locked.
public
isAccountNonLocked() : bool
Internally, if this method returns false, the authentication system will throw a LockedException and prevent login.
Tags
Return values
bool —true if the user is not locked, false otherwise
isCredentialsNonExpired()
Checks whether the user's credentials (password) has expired.
public
isCredentialsNonExpired() : bool
Internally, if this method returns false, the authentication system will throw a CredentialsExpiredException and prevent login.
Tags
Return values
bool —true if the user's credentials are non expired, false otherwise
isEnabled()
Checks whether the user is enabled.
public
isEnabled() : bool
Internally, if this method returns false, the authentication system will throw a DisabledException and prevent login.
Tags
Return values
bool —true if the user is enabled, false otherwise