コード例 #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());
 }
コード例 #2
0
 /**
  * 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) {
     }
 }