Exemple #1
0
 /**
  * @inheritdoc
  */
 public function consume(TokenInterface $token, Request $request)
 {
     if ($token->isConsumed()) {
         throw new \Exception(sprintf('Token "%s" is consumed, cannot consume tokens twice', $token->getName()));
     }
     $token->setConsumed(true);
     return null;
 }
Exemple #2
0
 public function authenticate(TokenInterface $token)
 {
     $user = $this->userProvider->loadUserByUsername($token->getUsername());
     if (!$user) {
         throw new AuthenticationException("Bad credentials... Did you forgot your username ?");
     }
     if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
         // ...
     }
 }
 /**
  * {@inheritdoc}
  */
 public function scoreArgument($argument)
 {
     if (!$argument instanceof \Traversable && !is_array($argument)) {
         return false;
     }
     $scores = array();
     foreach ($argument as $key => $argumentEntry) {
         $scores[] = $this->value->scoreArgument($argumentEntry);
     }
     if (empty($scores) || in_array(false, $scores, true)) {
         return false;
     }
     return array_sum($scores) / count($scores);
 }
Exemple #4
0
 /**
  * @param TokenInterface $token
  * @return UserInterface
  */
 public function getUser(TokenInterface $token)
 {
     return $this->source->findByPK($token->userPK());
 }