From 296cf3e34bcc26d53a184b80caaa35e407170408 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 4 Jun 2024 15:37:41 -0700 Subject: [PATCH] Update OauthClients component --- app/Livewire/OauthClients.php | 24 ++++++------------- .../views/livewire/oauth-clients.blade.php | 4 ++-- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/app/Livewire/OauthClients.php b/app/Livewire/OauthClients.php index d3803a7b28..f621e8ed9c 100644 --- a/app/Livewire/OauthClients.php +++ b/app/Livewire/OauthClients.php @@ -19,21 +19,11 @@ class OauthClients extends Component public $authorizationError; - protected $clientRepository; - protected $tokenRepository; - - public function __construct() - { - $this->clientRepository = app(ClientRepository::class); - $this->tokenRepository = app(TokenRepository::class); - parent::__construct(); - } - public function render() { return view('livewire.oauth-clients', [ - 'clients' => $this->clientRepository->activeForUser(auth()->user()->id), - 'authorized_tokens' => $this->tokenRepository->forUser(auth()->user()->id)->where('revoked', false), + 'clients' => app(ClientRepository::class)->activeForUser(auth()->user()->id), + 'authorized_tokens' => app(TokenRepository::class)->forUser(auth()->user()->id)->where('revoked', false), ]); } @@ -44,7 +34,7 @@ class OauthClients extends Component 'redirect' => 'required|url|max:255', ]); - $newClient = $this->clientRepository->create( + $newClient = app(ClientRepository::class)->create( auth()->user()->id, $this->name, $this->redirect, @@ -58,7 +48,7 @@ class OauthClients extends Component // test for safety // ->delete must be of type Client - thus the model binding if ($clientId->user_id == auth()->user()->id) { - $this->clientRepository->delete($clientId); + app(ClientRepository::class)->delete($clientId); } else { Log::warning('User ' . auth()->user()->id . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->user_id); $this->authorizationError = 'You are not authorized to delete this client.'; @@ -67,9 +57,9 @@ class OauthClients extends Component public function deleteToken($tokenId): void { - $token = $this->tokenRepository->find($tokenId); + $token = app(TokenRepository::class)->find($tokenId); if ($token->user_id == auth()->user()->id) { - $this->tokenRepository->revokeAccessToken($tokenId); + app(TokenRepository::class)->revokeAccessToken($tokenId); } else { Log::warning('User ' . auth()->user()->id . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->user_id); $this->authorizationError = 'You are not authorized to delete this token.'; @@ -93,7 +83,7 @@ class OauthClients extends Component 'editRedirect' => 'required|url|max:255', ]); - $client = $this->clientRepository->find($editClientId->id); + $client = app(ClientRepository::class)->find($editClientId->id); if ($client->user_id == auth()->user()->id) { $client->name = $this->editName; $client->redirect = $this->editRedirect; diff --git a/resources/views/livewire/oauth-clients.blade.php b/resources/views/livewire/oauth-clients.blade.php index 5b789d0e0e..ed6b2ae272 100644 --- a/resources/views/livewire/oauth-clients.blade.php +++ b/resources/views/livewire/oauth-clients.blade.php @@ -311,7 +311,7 @@ - \ No newline at end of file +