Example #1
0
 /**
  * {@inheritdoc}
  */
 public function isTokenValid(CsrfToken $token)
 {
     if (!$this->storage->hasToken($token->getId())) {
         return false;
     }
     return hash_equals($this->storage->getToken($token->getId()), $token->getValue());
 }
 /**
  * Constructor
  *
  * @param $tokenStorage
  */
 public function __construct($tokenStorage)
 {
     $this->tokenStorage = $tokenStorage;
     try {
         if ($this->tokenStorage) {
             $token = $this->tokenStorage->getToken();
             if ($token) {
                 $this->user = $token->getUser();
             }
         }
     } catch (AuthenticationCredentialsNotFoundException $e) {
     }
 }
 /**
  * Tests if a CSRF token is stored.
  *
  * @return bool
  */
 private function hasStoredCsrfToken()
 {
     if (!isset($this->csrfTokenStorage)) {
         return true;
     }
     return $this->csrfTokenStorage->hasToken($this->csrfTokenIntention);
 }