Skip to content

A free open source IT asset/license management system

Update OauthClients component

Marcus Moore296cf3e34bcc
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 @@
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
- window.livewire.on('openModal', () => {
+ Livewire.on('openModal', () => {
$('#modal-create-client').modal('show').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});
@@ -330,4 +330,4 @@
</script>
-</div>
\ No newline at end of file
+</div>