From 43c6f4dc0a7ab2a51577928ade6b45aec1e9670e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 17 Nov 2020 11:10:41 +0100 Subject: [PATCH] Support accessing the MultifactorAuthenticationForm when logged in --- .../MultifactorAuthenticationForm.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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); } -- 2.20.1