metabase icon indicating copy to clipboard operation
metabase copied to clipboard

feat: support laravel 10

Open kingdeveloper6200 opened this issue 1 year ago • 2 comments

kingdeveloper6200 avatar Sep 24 '23 15:09 kingdeveloper6200

Thank you for your contribution, here is a few suggestions:

  1. Remove unnecessary changes
  2. After this change, does the library still work for Laravel 8?

uyab avatar Sep 25 '23 19:09 uyab

In lcobucci/jwt v5 Builder is now immutable, calls to methods of $builder such as $builder->withClaim() no longer modify the instance, thus, a token with an empty body is generated...

image

image

        $builder = $config
            ->builder();

        if ($dashboard) {
            $builder->withClaim('resource', ['dashboard' => $dashboard]);
        } elseif ($question) {
            $builder->withClaim('resource', ['question' => $question]);
            $this->type = 'question';
        } else {
            throw new InvalidArgumentException('Dashboard or question must be specified');
        }

        $params = $this->params;
        if (empty($params)) {
            $params = (object) $params;
        }
        $builder->withClaim('params', $params);

        dd($dashboard, $builder);

image

Following the upgrade guide and reassigning the $build variable to the return value of every method called seems to work, I don't know if this should be considered as a "clean" solution though 😅

        $builder = $config
            ->builder();

        if ($dashboard) {
            $builder = $builder->withClaim('resource', ['dashboard' => $dashboard]);
        } elseif ($question) {
            $builder = $builder->withClaim('resource', ['question' => $question]);
            $this->type = 'question';
        } else {
            throw new InvalidArgumentException('Dashboard or question must be specified');
        }

        $params = $this->params;
        if (empty($params)) {
            $params = (object) $params;
        }
        $builder = $builder->withClaim('params', $params);

        dd($dashboard, $builder);

image

image

tecncr avatar Feb 25 '24 20:02 tecncr