mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
everything working, cleanup
This commit is contained in:
parent
c28936fefb
commit
12e546e63a
|
@ -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');
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue