Skip to content

A free open source IT asset/license management system

everything working, cleanup

spencerrlongg12e546e63ac8
diff --git a/app/Http/Livewire/OauthClients.php b/app/Http/Livewire/OauthClients.php
index 55ace88374..98582c0725 100644
--- a/app/Http/Livewire/OauthClients.php
+++ b/app/Http/Livewire/OauthClients.php
@@ -2,9 +2,9 @@
namespace App\Http\Livewire;
+use Illuminate\Support\Facades\Log;
use Laravel\Passport\Client;
use Laravel\Passport\ClientRepository;
-use Laravel\Passport\Passport;
use Livewire\Component;
class OauthClients extends Component
@@ -15,6 +15,8 @@ class OauthClients extends Component
public $editName;
public $editRedirect;
+ public $authorizationError;
+
protected $clientRepository;
public function __construct()
@@ -58,6 +60,8 @@ class OauthClients extends Component
$this->editName = $editClientId->name;
$this->editRedirect = $editClientId->redirect;
+ $this->editClientId = $editClientId->id;
+
$this->dispatchBrowserEvent('editClient');
}
@@ -74,7 +78,8 @@ class OauthClients extends Component
$client->redirect = $this->editRedirect;
$client->save();
} else {
- // throw error
+ Log::warning('User ' . auth()->user()->id . ' attempted to edit client ' . $editClientId->id . ' which belongs to user ' . $client->user_id);
+ $this->authorizationError = 'You are not authorized to edit this client.';
}
$this->dispatchBrowserEvent('clientUpdated');
diff --git a/resources/views/livewire/oauth-clients.blade.php b/resources/views/livewire/oauth-clients.blade.php
index b98eb6283c..bb43fccbdb 100644
--- a/resources/views/livewire/oauth-clients.blade.php
+++ b/resources/views/livewire/oauth-clients.blade.php
@@ -183,6 +183,9 @@
@if($errors->has('newRedirect'))
<li>{{ $errors->first('newRedirect') }}</li>
@endif
+ @if($authCodeError)
+ <li>{{ $authorizationError }}</li>
+ @endif
</ul>
</div>
@endif
@@ -233,7 +236,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- <button type="button"
+ <button
class="btn btn-primary"
wire:click="updateClient('{{ $editClientId }}')"
>
@@ -244,17 +247,21 @@
</div>
</div>
<script>
- document.addEventListener('DOMContentLoaded', function () {
+ document.addEventListener('DOMContentLoaded', function() {
window.livewire.on('openModal', () => {
$('#modal-create-client').modal('show');
});
});
- window.addEventListener('clientCreated', event => {
+ window.addEventListener('clientCreated', function() {
$('#modal-create-client').modal('hide');
});
- window.addEventListener('editClient', event => {
+ window.addEventListener('editClient', function() {
$('#modal-edit-client').modal('show');
});
+ window.addEventListener('clientUpdated', function() {
+ $('#modal-edit-client').modal('hide');
+ });
+
</script>