From 19a17bc8513522bbca5a8e6ee6b8e4c89f334a32 Mon Sep 17 00:00:00 2001 From: FoskyM Date: Sun, 1 Oct 2023 22:10:21 +0800 Subject: [PATCH] fix: oauth --- src/Controllers/AuthorizeController.php | 9 +++++---- src/Storage.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Controllers/AuthorizeController.php b/src/Controllers/AuthorizeController.php index e210b87..c1a8f6a 100644 --- a/src/Controllers/AuthorizeController.php +++ b/src/Controllers/AuthorizeController.php @@ -35,14 +35,14 @@ class AuthorizeController implements RequestHandlerInterface $params = $request->getParsedBody(); - $oauth = new OAuth(); + $oauth = new OAuth($this->settings); $server = $oauth->server(); $request = $oauth->request()::createFromGlobals(); $response = $oauth->response(); if (!$server->validateAuthorizeRequest($request, $response)) { - $response->send(); - die; + $response->getResponseBody(); + return new JsonResponse(json_decode($response->getResponseBody(), true)); } $is_authorized = (Arr::get($params, 'authorized', 'no') === 'yes'); @@ -52,6 +52,7 @@ class AuthorizeController implements RequestHandlerInterface /* $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40); exit("SUCCESS! Authorization Code: $code");*/ } - $response->send(); + $response->getResponseBody(); + return new JsonResponse(json_decode($response->getResponseBody(), true)); } } diff --git a/src/Storage.php b/src/Storage.php index e99fea1..ba93f38 100644 --- a/src/Storage.php +++ b/src/Storage.php @@ -433,7 +433,7 @@ class Storage implements if ($result = Models\Scope::where('is_default', true)->get()) { $defaultScope = array_map(function ($row) { return $row['scope']; - }, $result); + }, $result->toArray()); return implode(' ', $defaultScope); }