diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-07-04 11:49:33 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-07-04 11:49:33 +0200 |
| commit | 414e0080d467297bbc00ca3ba12cce6112a7367d (patch) | |
| tree | 3eeab9e44f0b6ee61e79982b0e692ade7fde3d6c /lib | |
| parent | 175f5cd677ae75c33a9cbbf91896df5bfd885166 (diff) | |
fix redirect after login, fixes #5683
Closes #5683
Merge request studip/studip!4316
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/middleware/AuthenticationMiddleware.php | 8 | ||||
| -rw-r--r-- | lib/middleware/SeminarOpenMiddleware.php | 17 |
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/middleware/AuthenticationMiddleware.php b/lib/middleware/AuthenticationMiddleware.php index eb6ddd6..95d29ac 100644 --- a/lib/middleware/AuthenticationMiddleware.php +++ b/lib/middleware/AuthenticationMiddleware.php @@ -32,14 +32,6 @@ final class AuthenticationMiddleware implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if ($this->auth_manager->start()) { - if (isset($_SESSION['redirect_after_login'] ) && \User::findCurrent()) { - $redirect = $_SESSION['redirect_after_login']; - unset($_SESSION['redirect_after_login']); - - return $this->response_factory->createResponse(302) - ->withHeader('Location', $redirect); - } - return $handler->handle($request); } else { if (!match_route('dispatch.php/start')) { diff --git a/lib/middleware/SeminarOpenMiddleware.php b/lib/middleware/SeminarOpenMiddleware.php index a20a3ba..c4fdfb6 100644 --- a/lib/middleware/SeminarOpenMiddleware.php +++ b/lib/middleware/SeminarOpenMiddleware.php @@ -98,7 +98,7 @@ final class SeminarOpenMiddleware implements MiddlewareInterface } // user init starts here - if (is_object($user) && $user->id != "nobody") { + if (is_object($user) && $user->id !== 'nobody') { if ($_SESSION['SessionStart'] > \UserConfig::get($user->id)->CURRENT_LOGIN_TIMESTAMP) { // just logged in // store old CURRENT_LOGIN in LAST_LOGIN and set CURRENT_LOGIN to start of session \UserConfig::get($user->id)->store( @@ -116,7 +116,6 @@ final class SeminarOpenMiddleware implements MiddlewareInterface ) { $seminar_open_redirected = true; } - unset($_SESSION['redirect_after_login']); if (isset($_SESSION['contrast'])) { \UserConfig::get($GLOBALS['user']->id)->store('USER_HIGH_CONTRAST', $_SESSION['contrast']); unset($_SESSION['contrast']); @@ -183,13 +182,19 @@ final class SeminarOpenMiddleware implements MiddlewareInterface } if ($user_did_login) { - if (isset($_SESSION[\StudipAuthOAuth2::class]['redirect'])) { + \NotificationCenter::postNotification('UserDidLogin', $user->id); + + if (isset($_SESSION['redirect_after_login'])) { + $redirect = $_SESSION['redirect_after_login']; + unset($_SESSION['redirect_after_login']); + return $this->response_factory->createResponse(302) + ->withHeader('Location', \URLHelper::getURL($redirect)); + } elseif (isset($_SESSION[\StudipAuthOAuth2::class]['redirect'])) { $redirect = $_SESSION[\StudipAuthOAuth2::class]['redirect']; unset($_SESSION[\StudipAuthOAuth2::class]); - $response = $this->response_factory->createResponse(302); - return $response->withHeader('Location', \URLHelper::getURL($redirect)); + return $this->response_factory->createResponse(302) + ->withHeader('Location', \URLHelper::getURL($redirect)); } - \NotificationCenter::postNotification('UserDidLogin', $user->id); } if (!\Request::isXhr() && $perm->have_perm('root')) { |
