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 fdad97374..f3639a60a 100644 --- a/app/Http/Controllers/Auth/Login.php +++ b/app/Http/Controllers/Auth/Login.php @@ -84,7 +84,7 @@ class Login extends Controller return redirect('wizard'); } - return redirect('/'); + return redirect()->intended('/'); } public function destroy()