From 82fec7e281e168327b453676497f27de16ce5736 Mon Sep 17 00:00:00 2001
From: Jonathan Foucher <jfoucher@gmail.com>
Date: Mon, 5 Sep 2022 11:52:13 +0200
Subject: [PATCH] redirect to named routes

---
 app/Http/Controllers/Auth/LogoutController.php |  2 +-
 routes/web.php                                 | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/app/Http/Controllers/Auth/LogoutController.php b/app/Http/Controllers/Auth/LogoutController.php
index d2f6210a..b8aa70b4 100755
--- a/app/Http/Controllers/Auth/LogoutController.php
+++ b/app/Http/Controllers/Auth/LogoutController.php
@@ -24,6 +24,6 @@ public function logout()
             Auth::guard('web')->logout();
         }
 
-        return redirect('/');
+        return redirect(route('login'));
     }
 }
diff --git a/routes/web.php b/routes/web.php
index 409fba56..1e4d1eb4 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -3,7 +3,10 @@
 use App\Http\Controllers\PdfController;
 use App\Http\Controllers\UsersController;
 use Illuminate\Support\Facades\Route;
-
+use Illuminate\Support\Facades\Auth;
+use App\Http\Controllers\Auth\LoginController;
+use App\Http\Controllers\Auth\LogoutController;
+/*
 /*
 |--------------------------------------------------------------------------
 | Web Routes
@@ -15,11 +18,11 @@
 |
 */
 
-Route::get('/logout', [\App\Http\Controllers\Auth\LogoutController::class, 'logout'])->name('logout');
-Route::post('/login', [\App\Http\Controllers\Auth\LoginController::class, 'login'])->name('login');
+Route::get('/logout', [LogoutController::class, 'logout'])->name('logout');
+Route::post('/login', [LoginController::class, 'login'])->name('login');
 Route::get('/login', function () {
-    if (\Illuminate\Support\Facades\Auth::user()) {
-        return redirect('/');
+    if (Auth::user()) {
+        return redirect(route('home'));
     }
 
     return view('app');
@@ -40,7 +43,7 @@
 
 Route::get('/', function () {
     if (!Auth::user()) {
-        return redirect('/login');
+        return redirect(route('login'));
     }
 
     return view('app');
-- 
GitLab