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.

Refactor admin authentication and routing***

Andras Bacsai7e7f322e21f8
diff --git a/app/Livewire/Admin/Index.php b/app/Livewire/Admin/Index.php
index 75b3f1d226..95a7dd2aea 100644
--- a/app/Livewire/Admin/Index.php
+++ b/app/Livewire/Admin/Index.php
@@ -11,7 +11,10 @@ class Index extends Component
public $users = [];
public function mount()
{
- if (auth()->user()->id !== 0) {
+ if (!isCloud()) {
+ return redirect()->route('dashboard');
+ }
+ if (!isInstanceAdmin() && session('adminToken') === null) {
return redirect()->route('dashboard');
}
$this->users = User::whereHas('teams', function ($query) {
diff --git a/routes/web.php b/routes/web.php
index bb3ca6e345..12e3c4a8d3 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -79,9 +79,7 @@ use App\Livewire\Waitlist\Index as WaitlistIndex;
if (isDev()) {
Route::get('/dev/compose', Compose::class)->name('dev.compose');
}
-if (isCloud()) {
- Route::get('/admin', AdminIndex::class)->name('admin.index');
-}
+Route::get('/admin', AdminIndex::class)->name('admin.index');
Route::post('/forgot-password', [Controller::class, 'forgot_password'])->name('password.forgot');
Route::get('/api/v1/test/realtime', [Controller::class, 'realtime_test'])->middleware('auth');