public function getTokenExpiry()
 {
     $user = \Yii::$app->getUser();
     $sessionId = \Yii::$app->session->getId();
     if ($this->accessToken == null) {
         $this->accessToken = AccessToken::find()->where(['user_id' => $user->id])->andWhere(['session_id' => $sessionId])->one();
         if ($this->accessToken == null) {
             return 0;
         }
     }
     $createdDate = new \DateTime($this->accessToken->created);
     return ($createdDate->getTimestamp() + $user->authTimeout) * 1000;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public static function findIdentityByAccessToken($token, $type = null)
 {
     $tokenData = AccessToken::find($token)->where(['token' => $token])->one();
     if ($tokenData !== null) {
         $user = User::find()->where(['id' => $tokenData->user_id])->one();
         if ($user !== null) {
             return new static($user->toArray());
         } else {
             return null;
         }
     } else {
         return null;
     }
 }