From 7570918ff86fc92cf22c8c42d9418e67967a3a68 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Mon, 3 Dec 2018 13:45:33 +0300 Subject: [PATCH] redirect to intended url --- app/Exceptions/Handler.php | 3 +++ app/Http/Controllers/Auth/Login.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a747e31b8..28d29a8f2 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -56,6 +56,9 @@ class Handler extends ExceptionHandler */ protected function unauthenticated($request, AuthenticationException $exception) { + // Store the current uri in the session + session(['url.intended' => $request->url()]); + if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } diff --git a/app/Http/Controllers/Auth/Login.php b/app/Http/Controllers/Auth/Login.php index ea2aabbf8..e94f61062 100644 --- a/app/Http/Controllers/Auth/Login.php +++ b/app/Http/Controllers/Auth/Login.php @@ -79,7 +79,7 @@ class Login extends Controller return redirect($path); } - return redirect('/'); + return redirect()->intended('/'); } public function destroy()