mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
everything working, cleanup
This commit is contained in:
parent
c28936fefb
commit
12e546e63a
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Laravel\Passport\Client;
|
use Laravel\Passport\Client;
|
||||||
use Laravel\Passport\ClientRepository;
|
use Laravel\Passport\ClientRepository;
|
||||||
use Laravel\Passport\Passport;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class OauthClients extends Component
|
class OauthClients extends Component
|
||||||
|
@ -15,6 +15,8 @@ class OauthClients extends Component
|
||||||
public $editName;
|
public $editName;
|
||||||
public $editRedirect;
|
public $editRedirect;
|
||||||
|
|
||||||
|
public $authorizationError;
|
||||||
|
|
||||||
protected $clientRepository;
|
protected $clientRepository;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -58,6 +60,8 @@ class OauthClients extends Component
|
||||||
$this->editName = $editClientId->name;
|
$this->editName = $editClientId->name;
|
||||||
$this->editRedirect = $editClientId->redirect;
|
$this->editRedirect = $editClientId->redirect;
|
||||||
|
|
||||||
|
$this->editClientId = $editClientId->id;
|
||||||
|
|
||||||
$this->dispatchBrowserEvent('editClient');
|
$this->dispatchBrowserEvent('editClient');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +78,8 @@ class OauthClients extends Component
|
||||||
$client->redirect = $this->editRedirect;
|
$client->redirect = $this->editRedirect;
|
||||||
$client->save();
|
$client->save();
|
||||||
} else {
|
} 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');
|
$this->dispatchBrowserEvent('clientUpdated');
|
||||||
|
|
|
@ -183,6 +183,9 @@
|
||||||
@if($errors->has('newRedirect'))
|
@if($errors->has('newRedirect'))
|
||||||
<li>{{ $errors->first('newRedirect') }}</li>
|
<li>{{ $errors->first('newRedirect') }}</li>
|
||||||
@endif
|
@endif
|
||||||
|
@if($authCodeError)
|
||||||
|
<li>{{ $authorizationError }}</li>
|
||||||
|
@endif
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@ -233,7 +236,7 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
|
||||||
<button type="button"
|
<button
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
wire:click="updateClient('{{ $editClientId }}')"
|
wire:click="updateClient('{{ $editClientId }}')"
|
||||||
>
|
>
|
||||||
|
@ -244,17 +247,21 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
window.livewire.on('openModal', () => {
|
window.livewire.on('openModal', () => {
|
||||||
$('#modal-create-client').modal('show');
|
$('#modal-create-client').modal('show');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
window.addEventListener('clientCreated', event => {
|
window.addEventListener('clientCreated', function() {
|
||||||
$('#modal-create-client').modal('hide');
|
$('#modal-create-client').modal('hide');
|
||||||
});
|
});
|
||||||
window.addEventListener('editClient', event => {
|
window.addEventListener('editClient', function() {
|
||||||
$('#modal-edit-client').modal('show');
|
$('#modal-edit-client').modal('show');
|
||||||
});
|
});
|
||||||
|
window.addEventListener('clientUpdated', function() {
|
||||||
|
$('#modal-edit-client').modal('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue