PHP Class Webiny\Component\Security\User\AbstractUser

You can optionally extend this class if you want to inherit the common getter functions.
Inheritance: implements Webiny\Component\Security\User\UserInterface, use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
authenticate ( Login $login, Firewall $firewall ) : boolean This method verifies the credentials of current user with the credentials provided from the Login object.
getAuthProviderName ( ) : string Returns the name of auth provider.
getPassword ( ) : string
getRoles ( ) : array Get a list of assigned roles
getUserProviderName ( ) : string Returns the name of user provider.
getUsername ( ) : string
hasRole ( string $role ) : boolean Check if current user has the defined role.
isAuthenticated ( ) : boolean Check if user is already authenticated.
isTokenValid ( TokenData $tokenData ) : boolean This method compares the $tokenData against the current user and returns true if users are identical, otherwise false is returned.
populate ( string $username, string $password, array $roles, boolean $isAuthenticated = false ) Populate the user object.
setAuthProviderName ( string $name ) Set the name of the auth provider.
setIsAuthenticated ( boolean $bool ) Sets the auth flag.
setRoles ( array $roles ) Sets the user roles.
setUserProviderName ( string $name ) Set the name of the user provider.

Method Details

authenticate() abstract public method

This method verifies the credentials of current user with the credentials provided from the Login object.
abstract public authenticate ( Login $login, Firewall $firewall ) : boolean
$login Webiny\Component\Security\Authentication\Providers\Login
$firewall Webiny\Component\Security\Authentication\Firewall
return boolean Return true if credentials are valid, otherwise return false.

getAuthProviderName() public method

Returns the name of auth provider.
public getAuthProviderName ( ) : string
return string

getPassword() public method

public getPassword ( ) : string
return string Hashed password.

getRoles() public method

Get a list of assigned roles
public getRoles ( ) : array
return array List of assigned roles.

getUserProviderName() public method

Returns the name of user provider.
public getUserProviderName ( ) : string
return string

getUsername() public method

public getUsername ( ) : string
return string Username.

hasRole() public method

Check if current user has the defined role.
public hasRole ( string $role ) : boolean
$role string Role name
return boolean True if user has the role, otherwise false.

isAuthenticated() public method

Check if user is already authenticated.
public isAuthenticated ( ) : boolean
return boolean True if user is authenticated, otherwise false.

isTokenValid() public method

This method compares the $tokenData against the current user and returns true if users are identical, otherwise false is returned.
public isTokenValid ( TokenData $tokenData ) : boolean
$tokenData Webiny\Component\Security\Token\TokenData
return boolean

populate() public method

Populate the user object.
public populate ( string $username, string $password, array $roles, boolean $isAuthenticated = false )
$username string Username.
$password string Hashed password.
$roles array Array of the assigned roles.
$isAuthenticated boolean Boolean flag that tells us if user is already authenticated or not.

setAuthProviderName() public method

Set the name of the auth provider.
public setAuthProviderName ( string $name )
$name string

setIsAuthenticated() public method

Sets the auth flag.
public setIsAuthenticated ( boolean $bool )
$bool boolean

setRoles() public method

Sets the user roles.
public setRoles ( array $roles )
$roles array An array of Role instances.

setUserProviderName() public method

Set the name of the user provider.
public setUserProviderName ( string $name )
$name string