From f99303408455291353a726d99446b6a4f7fa1485 Mon Sep 17 00:00:00 2001 From: ankurk91 Date: Wed, 12 Apr 2023 12:20:47 +0530 Subject: [PATCH 1/2] feat: allow to customize redirect url in AuthenticateSession Middleware --- .../Session/Middleware/AuthenticateSession.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Session/Middleware/AuthenticateSession.php b/src/Illuminate/Session/Middleware/AuthenticateSession.php index 1b3cee37ccb6..04134f4e6021 100644 --- a/src/Illuminate/Session/Middleware/AuthenticateSession.php +++ b/src/Illuminate/Session/Middleware/AuthenticateSession.php @@ -6,6 +6,7 @@ use Illuminate\Auth\AuthenticationException; use Illuminate\Contracts\Auth\Factory as AuthFactory; use Illuminate\Contracts\Session\Middleware\AuthenticatesSessions; +use Illuminate\Http\Request; class AuthenticateSession implements AuthenticatesSessions { @@ -94,7 +95,9 @@ protected function logout($request) $request->session()->flush(); - throw new AuthenticationException('Unauthenticated.', [$this->auth->getDefaultDriver()]); + throw new AuthenticationException( + 'Unauthenticated.', [$this->auth->getDefaultDriver()], $this->redirectTo($request) + ); } /** @@ -106,4 +109,15 @@ protected function guard() { return $this->auth; } + + /** + * Get the path the user should be redirected to when they are not authenticated. + * + * @param \Illuminate\Http\Request $request + * @return string|null + */ + protected function redirectTo(Request $request) + { + // + } } From bbf4873d253ca76d4367edbe9bb992fee7e5872f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 12 Apr 2023 08:15:15 -0500 Subject: [PATCH 2/2] Update AuthenticateSession.php --- src/Illuminate/Session/Middleware/AuthenticateSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Session/Middleware/AuthenticateSession.php b/src/Illuminate/Session/Middleware/AuthenticateSession.php index 04134f4e6021..7e96f683e0f6 100644 --- a/src/Illuminate/Session/Middleware/AuthenticateSession.php +++ b/src/Illuminate/Session/Middleware/AuthenticateSession.php @@ -111,7 +111,7 @@ protected function guard() } /** - * Get the path the user should be redirected to when they are not authenticated. + * Get the path the user should be redirected to when their session is not autheneticated. * * @param \Illuminate\Http\Request $request * @return string|null