mediatekformation

UserInterface

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 encoded 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
see
UserProviderInterface
author

Fabien Potencier fabien@symfony.com

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.

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

Search results