Exemplo n.º 1
0
 private function setTokens(UserInterface $user, Token $token = null, $remember = false)
 {
     if (!isset($token)) {
         $token = new Token($user->GetID());
     }
     $checksum = hash('md5', (string) $token);
     $expires = $remember ? strtotime('+' . $this->expiresDays . ' day') : 0;
     $tokenString = base64_encode((string) $token . '|' . $checksum);
     $this->session->Set('AuthUserID', $token->UserID);
     $this->session->Set('AuthToken', $tokenString);
     $this->cookies->Set('AuthToken', $tokenString, $expires);
     $this->tokenMapper->SaveAuthToken($token);
     return $tokenString;
 }
Exemplo n.º 2
0
 protected function getTokenString(UserInterface $user)
 {
     $now = new \DateTime('now', new \DateTimeZone('UTC'));
     $payload = [];
     $payload['userID'] = $user->GetID();
     $payload['iat'] = $now->format('U');
     $payload['exp'] = $now->add($this->expires)->format('U');
     return \Firebase\JWT\JWT::encode($payload, $this->secretKey, 'HS256');
 }