Skip to content

Commit 08a4855

Browse files
committed
check if user is logged in at the beginning of the code endpoint. if so, redirect to the redirect URL and do nothing
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent f1b7775 commit 08a4855

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ public function login(int $providerId, ?string $redirectUrl = null) {
358358
#[UseSession]
359359
#[BruteForceProtection(action: 'userOidcCode')]
360360
public function code(string $state = '', string $code = '', string $scope = '', string $error = '', string $error_description = '') {
361+
if ($this->userSession->isLoggedIn()) {
362+
$sessionKeySuffix = '-' . $state;
363+
$redirectUrl = $this->session->get(self::REDIRECT_AFTER_LOGIN . $sessionKeySuffix);
364+
$this->cleanupSessionState($sessionKeySuffix);
365+
return $this->getRedirectResponse(!empty($redirectUrl) ? $redirectUrl : null);
366+
}
361367
if (!$this->isSecure()) {
362368
return $this->buildProtocolErrorResponse();
363369
}

0 commit comments

Comments
 (0)