From 91bbd0d7a2a7d5102da6cee5876d0331005e20e2 Mon Sep 17 00:00:00 2001 From: mikeburg Date: Sat, 9 Dec 2023 18:17:17 -0800 Subject: [PATCH] oauth bug fixes. --- app/Http/Controllers/OAuth2Controller.php | 1 + .../Controllers/OauthClientController.php | 41 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/OAuth2Controller.php b/app/Http/Controllers/OAuth2Controller.php index da16dd30..aa6974cd 100644 --- a/app/Http/Controllers/OAuth2Controller.php +++ b/app/Http/Controllers/OAuth2Controller.php @@ -7,6 +7,7 @@ use App\Models\Person; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Auth; +use InvalidArgumentException; class OAuth2Controller extends ApiController { diff --git a/app/Http/Controllers/OauthClientController.php b/app/Http/Controllers/OauthClientController.php index 9e13919f..6864b501 100644 --- a/app/Http/Controllers/OauthClientController.php +++ b/app/Http/Controllers/OauthClientController.php @@ -32,62 +32,63 @@ public function index(): JsonResponse public function store(): JsonResponse { $this->authorize('store', OauthClient::class); - $client = new OauthClient; - $this->fromRest($client); + $oauthClient = new OauthClient; + $this->fromRest($oauthClient); - if ($client->save()) { - return $this->success($client); + if ($oauthClient->save()) { + return $this->success($oauthClient); } - return $this->restError($client); + return $this->restError($oauthClient); } /** * Display the specified OAuth Client. * - * @param OauthClient $client + * @param OauthClient $oauthClient * @return JsonResponse * @throws AuthorizationException */ - public function show(OauthClient $client): JsonResponse + public function show(OauthClient $oauthClient): JsonResponse { - $this->authorize('show', $client); - return $this->success($client); + $this->authorize('show', $oauthClient); + return $this->success($oauthClient); } /** * Update the specified OAuth Client in storage. * - * @param OauthClient $client + * @param OauthClient $oauthClient * @return JsonResponse * @throws AuthorizationException|ValidationException */ - public function update(OauthClient $client): JsonResponse + public function update(OauthClient $oauthClient): JsonResponse { - $this->authorize('update', $client); - $this->fromRest($client); + error_log('** MODEL '.json_encode($oauthClient)); + $this->authorize('update', $oauthClient); + $this->fromRest($oauthClient); - if ($client->save()) { - return $this->success($client); + if ($oauthClient->save()) { + return $this->success($oauthClient); } - return $this->restError($client); + return $this->restError($oauthClient); } /** * Delete an OAuth Client record * - * @param OauthClient $client + * @param OauthClient $oauthClient * @return JsonResponse * @throws AuthorizationException */ - public function destroy(OauthClient $client): JsonResponse + public function destroy(OauthClient $oauthClient): JsonResponse { - $this->authorize('destroy', $client); - $client->delete(); + $this->authorize('destroy', $oauthClient); + $oauthClient->delete(); return $this->restDeleteSuccess(); } }