Symfony\Component\Security\Authentication\Token\TokenInterface::setAuthenticated PHP Method

setAuthenticated() public method

Sets the authenticated flag.
public setAuthenticated ( boolean $isAuthenticated )
$isAuthenticated boolean The authenticated flag
    function setAuthenticated($isAuthenticated);

Usage Example

示例#1
0
 /**
  * Refreshes the user by reloading it from the user provider
  *
  * @param TokenInterface $token
  *
  * @return TokenInterface|null
  */
 protected function refreshUser(TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof AccountInterface) {
         return $token;
     }
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('Reloading user from user provider.'));
     }
     foreach ($this->userProviders as $provider) {
         try {
             $cUser = $provider->loadUserByAccount($user);
             $token->setRoles($cUser->getRoles());
             $token->setUser($cUser);
             if (false === $cUser->equals($user)) {
                 $token->setAuthenticated(false);
             }
             return $token;
         } catch (UnsupportedAccountException $unsupported) {
             // let's try the next user provider
         } catch (UsernameNotFoundException $notFound) {
             return null;
         }
     }
     throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
 }
All Usage Examples Of Symfony\Component\Security\Authentication\Token\TokenInterface::setAuthenticated