diff --git a/app/Livewire/DevQuickLogin.php b/app/Livewire/DevQuickLogin.php new file mode 100644 index 0000000..d1d5651 --- /dev/null +++ b/app/Livewire/DevQuickLogin.php @@ -0,0 +1,25 @@ +isLocal() && env('ALLOW_QUICK_LOGIN', false), 403); + + $user = User::withoutGlobalScopes()->where('email', $email)->firstOrFail(); + auth()->login($user); + $this->redirect('/dashboard'); + } + + public function render() + { + $users = User::withoutGlobalScopes()->get(['id', 'name', 'email', 'uuid']); + return view('livewire.dev-quick-login', compact('users')); + } +} diff --git a/resources/views/livewire/dev-quick-login.blade.php b/resources/views/livewire/dev-quick-login.blade.php new file mode 100644 index 0000000..7c54cb8 --- /dev/null +++ b/resources/views/livewire/dev-quick-login.blade.php @@ -0,0 +1,14 @@ +
+

Quick Login (Dev Only)

+
+ @foreach($users as $user) + + @endforeach +
+
diff --git a/routes/web.php b/routes/web.php index f523bab..b182d68 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,3 +16,8 @@ Route::get('/lizenz-abgelaufen', fn() => view('lizenz-abgelaufen'))->name('lizen Route::view('profile', 'profile')->middleware(['auth'])->name('profile'); require __DIR__.'/auth.php'; + +// Quick-Login: double-defense (isLocal + ALLOW_QUICK_LOGIN env) +if (app()->isLocal() && env('ALLOW_QUICK_LOGIN', false)) { + Route::get('/dev/quick-login', \App\Livewire\DevQuickLogin::class)->name('dev.quick-login'); +} diff --git a/tests/Feature/QuickLogin/QuickLoginTest.php b/tests/Feature/QuickLogin/QuickLoginTest.php new file mode 100644 index 0000000..b2cdd07 --- /dev/null +++ b/tests/Feature/QuickLogin/QuickLoginTest.php @@ -0,0 +1,12 @@ +isLocal() — in testing env it's NOT local + // So the route should NOT be registered in test env + get('/dev/quick-login')->assertNotFound(); +});