Determine if the token has expired.

@param  array $token
@return bool
779360
protected function tokenExpired($token)
    {
        $expiresAt = Carbon::parse($token['created_at'])->addSeconds($this->expires);

        return $expiresAt->isPast();
    }
144953
public static function isPasswordResetTokenValid($token)
    {
        if (empty($token)) {
            return false;
        }
        $timestamp = (int)substr($token, strrpos($token, '_') + 1);
        $expire = UsersModule::module()->passwordResetTokenExpire;
        return $timestamp + $expire >= time();
    }
750676
public function expireByToken($token)
    {
        $token = $this->findByToken($token);

        if (! is_null($token)) {
            return $token->expire();
        }
    }
175361
public function exists($token)
    {
        $reset = PasswordReset::where('token', $token)->first();
        return $reset and ! $reset->isExpired();
    }
906483
protected function checkToken($token)
    {
        if (!$token) {
            return false;
        }

        $file = $this->pathForToken($token);
        $content = null;

        if (file_exists($file)) {
            $content = file_get_contents($file);
            unlink($file);
        }

        return $content === $token;
    }
964063
public function loginViaToken($token)
    {
        $user = $this->userDao->getUserByToken($token);
        if ($user) {
            $this->loginWithoutPassword($user->getLogin());
            return true;
        } else {
            return false;
        }
    }
755498
public function validate($token)
    {
        if ($this->hasCache()) {
            $body = $this->getCache()->get($token);

            // Check if token is expired
            if (!is_null($body)) {
                $body = json_decode($body, true);
                if (new \DateTime($body['expire_at']) >= new \DateTime()) {
                    return $this->buildValidationReturn($body);
                } else {
                    $this->getCache()->delete($token);
                    throw new TokenException('The provided token is expired');
                }
            }
        }

        $request = (new RequestDescriptor())
            ->setUrl($this->buildUrl(sprintf('/api/token/validate?token=%s', (string) $token)))
            ->setMethod('GET');

        try {
            $body = json_decode($this->send($request)->getBody(), true);

            if ($this->hasCache()) {
                $this->getCache()->set(
                    $token,
                    json_encode($body),
                    (new \DateTime())->diff(new \DateTime($body['expire_at']))
                );
            }

            return $this->buildValidationReturn($body);
        } catch (ApiClientException $e) {
            $previous = $e->getPrevious();

            if ($previous instanceof BadResponseException) {
                $error = json_decode($previous->getResponse()->getBody(true), true);

                throw new TokenException($error['error'], $error['code'], $previous);
            }

            throw new TokenException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }
1183920
private function tokenExists($token)
    {
        $tokenData = $this->getTokenData($token);
        if ($tokenData == false) {
            return false;
        }

        return $tokenData == false ? true : false;
    }
708254
public function checkToken($token)
    {
        return (bool) $this->token()->where('token', $token)->where('expiration_date', '>', Carbon::now())->count();
    }
185165
public static function isPasswordResetTokenValid($token)
    {
        if (empty($token)) {
            return false;
        }
        $expire = Yii::$app->cms->passwordResetTokenExpire;
        $parts = explode('_', $token);
        $timestamp = (int)end($parts);
        return $timestamp + $expire >= time();
    }
631479
public function validateToken($token)
    {
        if (isset($_SESSION[$this->session_name])) {
            if ($_SESSION[$this->session_name] === $token) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
6298
public static function isTokenValid(string $token): bool
    {
        if (!static::hasTokenStored()) {
            return false;
        }

        $storedToken = static::getStoredToken();
        return $storedToken->getToken() === $token;
    }
1370954
public function validateRequest($token)
    {

        // If no token was sent, don't try to _validate it.
        if (empty($token)) {
            $this->_badToken401();
        }

        $validateResponse = $this->_validate($token);

        // If the result is not an array or doesn't contain a subject, send a 401
        if ((!is_array($validateResponse)) || (!array_key_exists('sub', $validateResponse))) {
            $this->_badToken401();
        }

        if (array_key_exists('sub', $validateResponse)) {
            $this->_tokenData = $validateResponse;
            $this->_setPrincipal();
            $this->_setAttributes();
        }

        return true;
    }
438840
protected function getValueOfToken(array $token)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_QUOTED_STRING:
                return substr($token[Lexer::VALUE], 1, -1);

            case Lexer::T_NUMBER:
                return (float)$token[Lexer::VALUE];

            case Lexer::T_TRUE:
                return true;

            case Lexer::T_FALSE:
                return false;

            case Lexer::T_NULL:
                return null;
        }

        return null;
    }
1231922
protected function validateRefresh(array $payload)
    {
        if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL)->isPast()) {
            throw new TokenExpiredException('Token has expired and can no longer be refreshed', 400);
        }

        return true;
    }
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();
    }
208452
public function isValidToken($token)
    {
        if (! $token) {
            return false;
        }

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

        return $tokenModel ? $tokenModel->isValid() : false;
    }