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()