UserInterface
in
Represents the interface that all user classes must implement.
This interface is useful because the authentication layer can deal with the object through its lifecycle, using the object to get the hashed password (for checking against a submitted password), assigning roles and so on.
Regardless of how your users are loaded or where they come from (a database, configuration, web service, etc.), you will have a class that implements this interface. Objects that implement this interface are created and loaded by different objects that implement UserProviderInterface.
Tags
Table of Contents
Methods
- eraseCredentials() : mixed
- Removes sensitive data from the user.
- getRoles() : array<string|int, string>
- Returns the roles granted to the user.
- getUserIdentifier() : string
- Returns the identifier for this user (e.g. username or email address).
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.
getRoles()
Returns the roles granted to the user.
public
getRoles() : array<string|int, 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, string>getUserIdentifier()
Returns the identifier for this user (e.g. username or email address).
public
getUserIdentifier() : string