From 9f992f003d4d31e77d8f16e348462b0e0255501f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 1 Nov 2015 08:03:41 +0100 Subject: [PATCH] Fix redirect loop. --- app/Http/Controllers/Auth/AuthController.php | 14 ++++++++++++++ app/Http/Middleware/Authenticate.php | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index f997fe5060..603c6c3d3b 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -13,6 +13,7 @@ use Request as Rq; use Session; use Twig; use Validator; +use Log; /** * Class AuthController @@ -23,6 +24,19 @@ class AuthController extends Controller { use AuthenticatesAndRegistersUsers, ThrottlesLogins; + /** + * Log the user out of the application. + * + * @return \Illuminate\Http\Response + */ + public function getLogout() + { + Auth::logout(); + Log::debug('Logout and redirect to root.'); + + return redirect('/login'); + } + /** * Show the application registration form. * diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 23026e7bde..8b196c51c8 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -7,7 +7,7 @@ use Config; use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; use Preferences; - +use Auth; /** * Class Authenticate * @@ -54,7 +54,8 @@ class Authenticate } if (intval($this->auth->user()->blocked) == 1) { - return redirect()->route('logout'); + Auth::logout(); + return redirect()->route('index'); } // if logged in, set user language: