Skip to content

Commit

Permalink
[BUGFIX] LoginController should redirect a logged-in user
Browse files Browse the repository at this point in the history
If a user is already logged in do not restart
the authentication process, but simply redirect
as it would happen after a successful login.

Resolves: #161
  • Loading branch information
liayn committed Aug 1, 2024
1 parent 65a9d86 commit 2c7cbe7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Classes/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace Causal\Oidc\Controller;

use Causal\Oidc\Service\OpenIdConnectService;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Http\ServerRequest;
Expand Down Expand Up @@ -66,8 +67,9 @@ public function login(string $_, ?array $pluginConfiguration)
$this->pluginConfiguration = $pluginConfiguration;
}

$context = GeneralUtility::makeInstance(Context::class);
$loginType = $this->request->getParsedBody()['logintype'] ?? $this->request->getQueryParams()['logintype'] ?? '';
if ($loginType === 'login') {
if ($loginType === 'login' || $context->getAspect('frontend.user')->isLoggedIn()) {
$redirectUrl = $this->determineRedirectUrl();
$this->redirect($redirectUrl);
}
Expand Down

0 comments on commit 2c7cbe7

Please sign in to comment.