Refactor admin authentication and routing***

***Add redirect for non-cloud users and instance admins without admin token.***

***Always include admin route, regardless of cloud status.
This commit is contained in:
Andras Bacsai 2024-02-08 14:01:16 +01:00
parent 9350fb4b97
commit 7e7f322e21
2 changed files with 5 additions and 4 deletions

View File

@ -11,7 +11,10 @@ class Index extends Component
public $users = []; public $users = [];
public function mount() public function mount()
{ {
if (auth()->user()->id !== 0) { if (!isCloud()) {
return redirect()->route('dashboard');
}
if (!isInstanceAdmin() && session('adminToken') === null) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
$this->users = User::whereHas('teams', function ($query) { $this->users = User::whereHas('teams', function ($query) {

View File

@ -79,9 +79,7 @@
if (isDev()) { if (isDev()) {
Route::get('/dev/compose', Compose::class)->name('dev.compose'); 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::post('/forgot-password', [Controller::class, 'forgot_password'])->name('password.forgot');
Route::get('/api/v1/test/realtime', [Controller::class, 'realtime_test'])->middleware('auth'); Route::get('/api/v1/test/realtime', [Controller::class, 'realtime_test'])->middleware('auth');