Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function createToken(Request $request, Response $response, UserInterface $user)
 {
     $this->session->set($this->key, $user->primaryKey());
     return $response;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function createToken(UserInterface $user)
 {
     return new SessionToken($user->primaryKey());
 }
Exemplo n.º 3
0
 /**
  * must automatic store token into database
  *
  * @param UserInterface $user
  * @param int           $lifetime
  * @return TokenInterface
  */
 public function createToken(UserInterface $user, $lifetime)
 {
     /**
      * @var AbstractToken $token
      */
     $token = $this->create();
     /*
      * Configuring token attributes.
      */
     $token->tokenCode = $this->generateHash();
     $token->setField('hash', $this->hashes->makeHash($token->tokenCode));
     $token->setUserPK($user->primaryKey());
     $token->setField('selector', $this->generateSelector());
     $token->setField('series', $this->generateSeries());
     $token->setExpiration(new \DateTime("now + {$lifetime} seconds"));
     if (!$this->save($token)) {
         throw new AuthException("Unable to save token to database");
     }
     return $token;
 }