Determine if the given token is valid.

@param  string  $token
@return bool
174378
protected function valid($token)
    {
        try {
            (new HttpClient)->get(
                $this->sparkUrl.'/api/token/'.$token.'/validate',
                ['verify' => __DIR__.'/cacert.pem']
            );

            return true;
        } catch (Exception $e) {
            var_dump($e->getMessage());

            return false;
        }
    }
570258
protected function validateToken($token)
    {
        if (!$token) return false;
        try {
            $invitation = UserInvitation::where('token', $token)
                ->where('state', 'pending')->first();
            if ($invitation) {
                if ( $invitation->token === $token) return $invitation;
            }
        } catch (ModelNotFoundException $e) {
            return false;
        }

        return false;
    }
694719
public function checkSignature($token = null)
    {
        $config_token = Api::getToken();
        $signature    = isset($_GET['signature']) ? $_GET['signature'] : null;
        $timestamp    = isset($_GET['timestamp']) ? $_GET['timestamp'] : null;
        $nonce        = isset($_GET['nonce']) ? $_GET['nonce'] : null;
        $token        = empty($token) ? $config_token : $token;
        $tmpArr       = [$token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        $tmpStr = sha1($tmpStr);

        if ($tmpStr == $signature && $signature != null) {
            return $this;
        }

        return false;
    }
194686
public static function check( $token )
    {
        $token_name = 'token';

        if(Session::exists($token_name) && $token == Session::exists($token_name) )
        {
            Session::delete($token_name);
            return true;
        }
        return false;
    }
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;
    }
1237326
public function verifyEmailToken($token)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$token = base64_decode($token);
		$vals = array(
			'token_hash' => $this->db->quoteValue(sha1($token)),
		);
		$query = Str::quickTemp('SELECT * FROM `email_tokens`
			WHERE `token_hash` = [::token_hash::]', $vals);
		$rows = $this->db->query($query)[0];
		$this->debug->table($rows, 'rows');
		if ($rows) {
			// found token in table
			$return = $rows[0]['userid'];
			// remove the token
			$where = $vals;
			$this->db->rowMan('email_tokens', null, $where);
			$this->log('pwForgotTokenSuccess', $rows[0]['userid']);
		} else {
			$this->log('pwForgotTokenFail');
		}
		$this->debug->groupEnd();
		return $return;
	}
316719
protected function validateStructure($token)
    {
        $parts = explode('.', $token);

        if (count($parts) !== 3) {
            throw new TokenInvalidException('Wrong number of segments');
        }

        $parts = array_filter(array_map('trim', $parts));

        if (count($parts) !== 3 || implode('.', $parts) !== $token) {
            throw new TokenInvalidException('Malformed token');
        }

        return $token;
    }
1193157
private function isConstantToken($token)
    {
        return $token == T_CONSTANT_ENCAPSED_STRING || $token == T_STRING || $token == T_LNUMBER || $token == T_DNUMBER;
    }
834224
public function verify($token = null) {
        if (!$token) {
            $data = $this->requestVerificationToken();
            $token = $data['token'];
        }

        return $this->_post('servers/' . $this->id . '/verify', ['token' => $token]);
    }
879185
public function isValid()
    {
        // if this token was not validated before...
        if ($this->validated === null) {
            // get the token value
            $token = $this->field->getValue();

            if (!empty($_SESSION) && !empty($_SESSION['csrftokens'])) {
                // if the token is in the list of valid tokens, this field is valid!
                $key = array_search($token, $_SESSION['csrftokens']);
                if ($key !== false) {
                    // invalidate the token as it has already been used.
                    unset($_SESSION['csrftokens'][$key]);

                    $this->validated = true;
                } else {
                    $this->validated = false;
                }
            } else {
                $this->validated = false;
            }
        }

        return $this->validated;
    }
283283
public function isTokenValid(string $token): bool
    {
        $tokenData = $this->decryptToken($token);

        return is_array($tokenData)
            && isset(
                $tokenData['user_id'],
                $tokenData['generated'],
                $tokenData['validForSeconds']
            );
    }
42736
public function deleteToken($token)
    {
        $tokenObject = $this->findToken($token);

        if ($tokenObject == null) {
            return (false);
        }
        $this->call($this->tyrUrl . '/' . $this->version . '/users/' . $this->user->id . '/keys/' . $tokenObject->id .'/', 'DELETE');
        return true;
    }
708254
public function checkToken($token)
    {
        return (bool) $this->token()->where('token', $token)->where('expiration_date', '>', Carbon::now())->count();
    }
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();
    }
964063
public function loginViaToken($token)
    {
        $user = $this->userDao->getUserByToken($token);
        if ($user) {
            $this->loginWithoutPassword($user->getLogin());
            return true;
        } else {
            return false;
        }
    }
1136984
public function contains(string $token): bool
    {
        $this->tokenize();
        return in_array($token, $this->tokens);
    }
110118
public static function isPasswordResetTokenValid(string $token) : bool
    {
        if (empty($token)) {
            return false;
        }
        $timestamp = (int) substr($token, strrpos($token, '_') + 1);
        $expire    = 3600;
        return $timestamp + $expire >= time();
    }