If no users exist redirect to /register from /login

If no users exist redirect to /register from /login
This commit is contained in:
cp6 2022-03-05 11:05:50 +11:00
parent 52a5c2427c
commit 6dfcaea04f

View File

@ -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');
}