From: Tim Düsterhus Date: Tue, 17 Nov 2020 10:10:41 +0000 (+0100) Subject: Support accessing the MultifactorAuthenticationForm when logged in X-Git-Tag: 5.4.0_Alpha_1~555^2~47^2~8 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=43c6f4dc0a7ab2a51577928ade6b45aec1e9670e;p=GitHub%2FWoltLab%2FWCF.git Support accessing the MultifactorAuthenticationForm when logged in --- diff --git a/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php b/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php index c8041e8e5d..eb2e743910 100644 --- a/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php +++ b/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php @@ -65,6 +65,14 @@ class MultifactorAuthenticationForm extends AbstractFormBuilderForm { public function readParameters() { parent::readParameters(); + if (!empty($_GET['url']) && ApplicationHandler::getInstance()->isInternalURL($_GET['url'])) { + $this->redirectUrl = $_GET['url']; + } + + if (WCF::getUser()->userID) { + $this->performRedirect(); + } + $this->user = WCF::getSession()->getPendingUserChange(); if (!$this->user) { throw new PermissionDeniedException(); @@ -94,10 +102,6 @@ class MultifactorAuthenticationForm extends AbstractFormBuilderForm { \assert($this->method->getDefinition()->definitionName === 'com.woltlab.wcf.multifactor'); $this->processor = $this->method->getProcessor(); - - if (!empty($_GET['url']) && ApplicationHandler::getInstance()->isInternalURL($_GET['url'])) { - $this->redirectUrl = $_GET['url']; - } } /** @@ -131,6 +135,13 @@ class MultifactorAuthenticationForm extends AbstractFormBuilderForm { public function saved() { AbstractForm::saved(); + $this->performRedirect(); + } + + /** + * Returns to the redirectUrl if given and to the landing page otherwise. + */ + protected function performRedirect() { if ($this->redirectUrl) { HeaderUtil::redirect($this->redirectUrl); }