проверяет валидность токена сброса пароля (по времени)
@param int $expired
@param string $token
@return boolean
323664
public static function isPasswordResetTokenValid(int $expired, string $token = null): bool
    {
        if ($token === null) {
            return false;
        }
        $parts = explode('_', $token);
        $timestamp = (int)end($parts);
        return $timestamp + $expired >= time();
    }
632619
public function setExpiredAfter($expiredAfter)
    {
        if (!is_string($this->expiredAfterAttribute) || empty($this->expiredAfterAttribute)) {
            return false;
        }
        return (int)($this->{$this->expiredAfterAttribute} = (int)$expiredAfter);
    }
719861
public function findByActivationToken($token)
    {
        $userMeta = $this->userMeta->where('activation_token', $token)->first();

        if ($userMeta) {
            return $userMeta->user()->first();
        }

        return false;
    }
808194
public function isTokenExpired(string $token): bool
    {
        if (!$this->isTokenValid($token)) {
            throw new \InvalidArgumentException('This token is invalid');
        }
        $tokenData = $this->decryptToken($token);
        $tokenExpiration = $tokenData['generated'] + $tokenData['validForSeconds'];

        return $tokenExpiration < time();
    }
268566
protected function store_token($token) {
        if (!$this->system) {
            parent::store_token($token);
            return;
        }

        $this->accesstoken = $token;

        // Create or update a DB record with the new token.
        $persistedtoken = access_token::get_record(['issuerid' => $this->issuer->get('id')]);
        if ($token !== null) {
            if (!$persistedtoken) {
                $persistedtoken = new access_token();
                $persistedtoken->set('issuerid', $this->issuer->get('id'));
            }
            // Update values from $token. Don't use from_record because that would skip validation.
            $persistedtoken->set('token', $token->token);
            if (isset($token->expires)) {
                $persistedtoken->set('expires', $token->expires);
            } else {
                // Assume an arbitrary time span of 1 week for access tokens without expiration.
                // The "refresh_system_tokens_task" is run hourly (by default), so the token probably won't last that long.
                $persistedtoken->set('expires', time() + WEEKSECS);
            }
            $persistedtoken->set('scope', $token->scope);
            $persistedtoken->save();
        } else {
            if ($persistedtoken) {
                $persistedtoken->delete();
            }
        }
    }
1132889
public function moveToToken(Token $token) {

      if (!$token->isValid()) {
        $this->setValid(false);
        return new Token();
      }

      $tokenIndex = $token->getIndex();


      foreach ($this->collection as $index => $collectionToken) {
        if ($collectionToken->getIndex() === $tokenIndex) {
          $this->setPosition($index);
          return $collectionToken;
        }
      }

      $this->setValid(false);
      return new Token();
    }
432495
public static function findByActivationToken($token)
    {
        if (!static::isActivationTokenValid($token)) {
            return null;
        }
        return static::find()->where(['activation_token' => $token, 'status' => self::STATUS_REGISTERED])->limit(1)->one();
    }
425328
public static function findByPasswordResetToken($token)
    {
        $expire = Yii::$app->params['user.passwordResetTokenExpire'];
        $parts = explode('_', $token);
        $timestamp = (int) end($parts);
        if ($timestamp + $expire < time()) {
            // token expired
            return null;
        }

        return static::findOne([
            'password_reset_token' => $token,
            'status' => self::STATUS_ACTIVE,
        ]);
    }
781987
public function index($token)
    {
        // Validate token
        /** @var $resetToken ResetPasswordModel */
        $resetToken = $this->resetPasswordRepository->getByToken($token);
        if (empty($resetToken) || $resetToken->isUsed()) {
            return view('nodes.api::reset-password.invalid');
        }

        // Check if token's expiry date has been exceed
        if ($resetToken->isExpired()) {
            return view('nodes.api::reset-password.expired');
        }

        return view('nodes.api::reset-password.form', compact('token'));
    }
708254
public function checkToken($token)
    {
        return (bool) $this->token()->where('token', $token)->where('expiration_date', '>', Carbon::now())->count();
    }
34354
public function deleteExpiredTokens()
    {
        $lifetime = config('autologin.lifetime');

        $expiry = Carbon::now()->subMinutes($lifetime);

        return $this->provider->deleteExpiredTokens($expiry);
    }
509303
public function deleteToken($token)
    {
        return $this->queryBuilder->from($this->getTokenTable())
            ->where('token', $token)
            ->delete();
    }
750676
public function expireByToken($token)
    {
        $token = $this->findByToken($token);

        if (! is_null($token)) {
            return $token->expire();
        }
    }
208452
public function isValidToken($token)
    {
        if (! $token) {
            return false;
        }

        /**
         * @var $tokenModel Token
         */
        $tokenModel = $this->tokens()->where('token', $token)->first();

        return $tokenModel ? $tokenModel->isValid() : false;
    }
837772
public function check($token)
    {
        $blacklistedToken = $this->model
            ->where('user_id', $this->Token->getSubject($token))
            ->where('expiry', '>', Carbon::now())
            ->whereToken($token)
            ->first();

        if ($blacklistedToken === null) {
            return true;
        }

        throw new BlacklistedTokenException();
    }
128910
private function _isAdmin($token)
    {
        foreach ($token->getRoles() as $role) {
            if (in_array($role->getRole(), ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'])) {
                return true;
            }
        }
        return false;
    }
1361275
public function expireAuthorizationCode($token)
    {
        $authCodeDataMapper = $this->getTokenDataMapper(Entity\AuthorizationCode::class);

        $authorizationCode = $authCodeDataMapper->findByToken($token);
        $authorizationCode->setExpiryDate(new DateTime());

        $authCodeDataMapper->save($authorizationCode);
    }