Verify token

@param string $token Token
@return bool|\Cake\Datasource\EntityInterface
326096
public function verify($token)
    {
        $result = $this->find('token', compact('token'))->firstOrFail();

        $event = $this->dispatchEvent('Muffin/Tokenize.beforeVerify', ['token' => $result]);
        if ($event->isStopped()) {
            return false;
        }

        if (!empty($result['foreign_data'])) {
            $table = $this->foreignTable($result);
            $fields = $result['foreign_data'];
            $conditions = [(string)$table->getPrimaryKey() => $result['foreign_key']];
            $table->updateAll($fields, $conditions);
        }

        $result->set('status', true);
        $this->save($result);

        $this->dispatchEvent('Muffin/Tokenize.afterVerify', ['token' => $result]);

        return $result;
    }
875581
public function isValid($token)
    {
        try {
            $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem'));

            $jws = SimpleJWS::load($token);

            return $jws->verify($publicKey, self::ALG) && $this->isTokenNotExpired($token);
        } catch (\InvalidArgumentException $ex) {
            return false;
        }
    }
287960
public function verify(string $token, string $provider, string $musked)
  {
    $userToken = VerifiedUser::where('token', $token)->first();

    if ($userToken == null) return false;
    $userEmail = $userToken->email;

    $model = config("auth.provider.{$provider}.model")::where($musked, $userEmail)->first();

    if ($model == null) return false;

    $userToken->delete();

    $model->update([
      'email_verified_at' => Carbon::now()
    ]);

    return $model;
  }
470301
public function decode($token)
    {
        try {
            // Let's never allow insecure tokens
            $jws = $this->jws->load($token, false);
        } catch (InvalidArgumentException $e) {
            throw new TokenInvalidException('Could not decode token: '.$e->getMessage(), $e->getCode(), $e);
        }

        if (! $jws->verify($this->getVerificationKey(), $this->getAlgo())) {
            throw new TokenInvalidException('Token Signature could not be verified.');
        }

        return (array) $jws->getPayload();
    }
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;
        }
    }
679571
public function decode($token)
    {
        try {
            $jwt = $this->parser->parse($token);
        } catch (Exception $e) {
            throw new TokenInvalidException('Could not decode token: '.$e->getMessage(), $e->getCode(), $e);
        }

        if (! $jwt->verify($this->signer, $this->getVerificationKey())) {
            throw new TokenInvalidException('Token Signature could not be verified.');
        }

        return (new Collection($jwt->getClaims()))->map(function ($claim) {
            return is_object($claim) ? $claim->getValue() : $claim;
        })->toArray();
    }
1136984
public function contains(string $token): bool
    {
        $this->tokenize();
        return in_array($token, $this->tokens);
    }
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;
    }
296090
public function verifyToken($token, $userId)
	{
		$user = $this->repository->get($userId);
		$now = new DateTime();

		if ($user) {
			$dateDiff = $now->diff($user->reset_password_requested_at);

			$totalHours = ($dateDiff->d * 24) + $dateDiff->h;

			// remove token older than 2h
			if ($totalHours > 2) {
				$update = [
					'reset_password_requested_at' => NULL,
					'reset_password_token' => NULL,
				];
				$this->repository->update($userId, $update);

				return FALSE;
			}

			if (Passwords::verify($token, $user->reset_password_token)) {
				$update = [
					'reset_password_requested_at' => NULL,
					'reset_password_token' => NULL,
				];
				$this->repository->update($userId, $update);

				return TRUE;
			}
		}

		return FALSE;
	}
1347288
public function isValid($token)
    {
        $this->validatePrepared();

        return $this->sessionBag->has(self::CSRF_TKN_NAME) && 
               $this->sessionBag->has(self::CSRF_TKN_TIME) && 
               $this->sessionBag->get(self::CSRF_TKN_NAME) === $token;
    }
391478
public function isTokenUnique($token) {

        $record = List_Unsubscribe_Token::where('token', $token)->first();

        if (!$record) {
            return true;
        }

        return false;
    }
1249760
protected function contains($token)
    {
        return stripos($this->whois, sprintf($token, $this->domain)) !== false;
    }
976949
public function contains( $token )
	{
		$token = (string) $token;
		$this->__validate( $token );

		return $this->__contains( $token );
	}
509303
public function deleteToken($token)
    {
        return $this->queryBuilder->from($this->getTokenTable())
            ->where('token', $token)
            ->delete();
    }
831972
public function verify($token)
    {
        $user = new User();
        if ($token === 'NULL' || $user->isToken($token) !== true) {
            Error::set(__printl('auth:error:token'), 'token');
        }
        if ($this->fail() !== true) {
            if (!(new User())->isLogin()) {
                $id = $user->getByWhere('token', $token)[0]['id'];
                $email = $user->getByWhere('token', $token)[0]['email'];
                $update = new Update();
                $update->update(['token' => 'NULL'], $id);
                $subject = __printl('auth:subject:verified');
                $link = __config()->auth->verification_link.'/'.$token;
                $html = __printl('auth:body:verified');
                $html = str_replace(':email', $email, $html);
                $email = new EmailHandler($subject, $html, $email);
                Success::set(__config()->auth->success->verified);
            } else {
                Error::set(__printl('auth:error:already:login'), 'login');
            }
        }
    }
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;
    }
1373854
public function userFromToken(string $token)
    {
        $user = $this->mapUserToObject($this->getUserByToken($token));
        return $user->setToken($token);
    }