mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Update OauthClients component
This commit is contained in:
parent
5a9a231359
commit
296cf3e34b
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue