From 6dfcaea04f1581a2a3831207dd8693d2bdee5211 Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 5 Mar 2022 11:05:50 +1100 Subject: [PATCH] If no users exist redirect to /register from /login If no users exist redirect to /register from /login --- app/Http/Controllers/Auth/AuthenticatedSessionController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index 09abe87..4d780de 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; +use App\Models\User; use App\Providers\RouteServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -17,6 +18,10 @@ class AuthenticatedSessionController extends Controller */ public function create() { + $users = User::all(); + if ($users->count() === 0) {//Only allow 1 user for this app + return redirect('/register'); + } return view('auth.login'); }