Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: able to select root permission easier

Andras Bacsaic4e702f0967c
diff --git a/app/Livewire/Security/ApiTokens.php b/app/Livewire/Security/ApiTokens.php
index 40752630e0..fe68a8ba55 100644
--- a/app/Livewire/Security/ApiTokens.php
+++ b/app/Livewire/Security/ApiTokens.php
@@ -15,6 +15,8 @@ class ApiTokens extends Component
public bool $readOnly = true;
+ public bool $rootAccess = false;
+
public array $permissions = ['read-only'];
public $isApiEnabled;
@@ -35,12 +37,11 @@ class ApiTokens extends Component
if ($this->viewSensitiveData) {
$this->permissions[] = 'view:sensitive';
$this->permissions = array_diff($this->permissions, ['*']);
+ $this->rootAccess = false;
} else {
$this->permissions = array_diff($this->permissions, ['view:sensitive']);
}
- if (count($this->permissions) == 0) {
- $this->permissions = ['*'];
- }
+ $this->makeSureOneIsSelected();
}
public function updatedReadOnly()
@@ -48,11 +49,30 @@ class ApiTokens extends Component
if ($this->readOnly) {
$this->permissions[] = 'read-only';
$this->permissions = array_diff($this->permissions, ['*']);
+ $this->rootAccess = false;
} else {
$this->permissions = array_diff($this->permissions, ['read-only']);
}
- if (count($this->permissions) == 0) {
+ $this->makeSureOneIsSelected();
+ }
+
+ public function updatedRootAccess()
+ {
+ if ($this->rootAccess) {
$this->permissions = ['*'];
+ $this->readOnly = false;
+ $this->viewSensitiveData = false;
+ } else {
+ $this->readOnly = true;
+ $this->permissions = ['read-only'];
+ }
+ }
+
+ public function makeSureOneIsSelected()
+ {
+ if (count($this->permissions) == 0) {
+ $this->permissions = ['read-only'];
+ $this->readOnly = true;
}
}
@@ -62,12 +82,6 @@ class ApiTokens extends Component
$this->validate([
'description' => 'required|min:3|max:255',
]);
- // if ($this->viewSensitiveData) {
- // $this->permissions[] = 'view:sensitive';
- // }
- // if ($this->readOnly) {
- // $this->permissions[] = 'read-only';
- // }
$token = auth()->user()->createToken($this->description, $this->permissions);
$this->tokens = auth()->user()->tokens;
session()->flash('token', $token->plainTextToken);
diff --git a/resources/views/livewire/security/api-tokens.blade.php b/resources/views/livewire/security/api-tokens.blade.php
index 6d94691b4e..1bcd647103 100644
--- a/resources/views/livewire/security/api-tokens.blade.php
+++ b/resources/views/livewire/security/api-tokens.blade.php
@@ -6,7 +6,8 @@
<div class="pb-4">
<h2>API Tokens</h2>
@if (!$isApiEnabled)
- <div>API is disabled. If you want to use the API, please enable it in the <a href="{{ route('settings.index') }}" class="underline dark:text-white">Settings</a> menu.</div>
+ <div>API is disabled. If you want to use the API, please enable it in the <a
+ href="{{ route('settings.index') }}" class="underline dark:text-white">Settings</a> menu.</div>
@else
<div>Tokens are created with the current team as scope. You will only have access to this team's resources.
</div>
@@ -25,7 +26,7 @@
@if ($permissions)
@foreach ($permissions as $permission)
@if ($permission === '*')
- <div>All (root/admin access), be careful!</div>
+ <div>Root access, be careful!</div>
@else
<div>{{ $permission }}</div>
@endif
@@ -35,6 +36,7 @@
</div>
<h4>Token Permissions</h4>
<div class="w-64">
+ <x-forms.checkbox label="Root Access" wire:model.live="rootAccess"></x-forms.checkbox>
<x-forms.checkbox label="Read-only" wire:model.live="readOnly"></x-forms.checkbox>
<x-forms.checkbox label="View Sensitive Data" wire:model.live="viewSensitiveData"></x-forms.checkbox>
</div>