vendor/scheb/two-factor-bundle/Security/Authentication/Voter/TwoFactorInProgressVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace Scheb\TwoFactorBundle\Security\Authentication\Voter;
  3. use Scheb\TwoFactorBundle\Security\Authentication\Token\TwoFactorTokenInterface;
  4. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  5. use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
  6. use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
  7. class TwoFactorInProgressVoter implements VoterInterface
  8. {
  9.     const IS_AUTHENTICATED_2FA_IN_PROGRESS 'IS_AUTHENTICATED_2FA_IN_PROGRESS';
  10.     public function vote(TokenInterface $token$subject, array $attributes)
  11.     {
  12.         if (!($token instanceof TwoFactorTokenInterface)) {
  13.             return VoterInterface::ACCESS_ABSTAIN;
  14.         }
  15.         foreach ($attributes as $attribute) {
  16.             if (self::IS_AUTHENTICATED_2FA_IN_PROGRESS === $attribute) {
  17.                 return VoterInterface::ACCESS_GRANTED;
  18.             }
  19.             if (AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY === $attribute) {
  20.                 return VoterInterface::ACCESS_GRANTED;
  21.             }
  22.         }
  23.         return VoterInterface::ACCESS_ABSTAIN;
  24.     }
  25. }