Webiny\Component\Security\User\AbstractUser::isAuthenticated PHP Méthode

isAuthenticated() public méthode

Check if user is already authenticated.
public isAuthenticated ( ) : boolean
Résultat boolean True if user is authenticated, otherwise false.
    public function isAuthenticated()
    {
        return $this->isAuthenticated;
    }

Usage Example

 /**
  * This function gets the current user object and needs to validate its access against the required roles.
  * The function must either return ACCESS_GRANTED, ACCESS_ABSTAIN or ACCESS_DENIED.
  *
  * @param AbstractUser $user           Current user instance.
  * @param array        $requestedRoles An array of requested roles for the current access map.
  *
  * @return integer ACCESS_GRANTED, ACCESS_ABSTAIN or ACCESS_DENIED.
  */
 public function vote(AbstractUser $user, array $requestedRoles)
 {
     $result = self::ACCESS_DENIED;
     if ($user->isAuthenticated()) {
         $result = self::ACCESS_GRANTED;
     }
     return $result;
 }