From: Tim Düsterhus Date: Thu, 19 Nov 2020 15:56:29 +0000 (+0100) Subject: Make the MF authentication controller for ACP inherit from the frontend ones X-Git-Tag: 5.4.0_Alpha_1~555^2~42^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2cb87f48faa95e3cacdd2bd24de7a5dc2a7cd275;p=GitHub%2FWoltLab%2FWCF.git Make the MF authentication controller for ACP inherit from the frontend ones --- diff --git a/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationAbortForm.class.php b/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationAbortForm.class.php index 8ca808df63..a6a4ae3956 100644 --- a/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationAbortForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationAbortForm.class.php @@ -1,10 +1,6 @@ userID) { - throw new PermissionDeniedException(); - } - - $user = WCF::getSession()->getPendingUserChange(); - if (!$user) { - $this->performRedirect(); - } - } - - /** - * @inheritDoc - */ - public function save() { - parent::save(); - - WCF::getSession()->clearPendingUserChange(); - - $this->saved(); - } - - /** - * @inheritDoc - */ - public function saved() { - parent::saved(); - - $this->performRedirect(); - } - +class MultifactorAuthenticationAbortForm extends \wcf\form\MultifactorAuthenticationAbortForm { /** * Returns to the landing page otherwise. */ protected function performRedirect() { HeaderUtil::redirect( - LinkHandler::getInstance()->getControllerLink(LoginForm::class) + LinkHandler::getInstance()->getLink('Login') ); exit; } - - /** - * @inheritDoc - */ - public function show() { - parent::show(); - - // It is not expected to reach this place, because the form should - // never be accessed via a direct link. - // If we reach it nonetheless we simply redirect back to the authentication - // form which contains the proper button to perform the submission. - HeaderUtil::redirect(LinkHandler::getInstance()->getControllerLink(MultifactorAuthenticationForm::class)); - exit; - } } diff --git a/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationForm.class.php b/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationForm.class.php index ffa6e55cc3..6b062408ad 100644 --- a/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MultifactorAuthenticationForm.class.php @@ -1,18 +1,5 @@ isInternalURL($_GET['url'])) { - $this->redirectUrl = $_GET['url']; - } - - if (WCF::getUser()->userID) { - $this->performRedirect(); - } - - $this->user = WCF::getSession()->getPendingUserChange(); - if (!$this->user) { - throw new PermissionDeniedException(); - } - - $this->setups = Setup::getAllForUser($this->user); - - if (empty($this->setups)) { - throw new \LogicException('Unreachable'); - } - - \uasort($this->setups, function (Setup $a, Setup $b) { - return $b->getObjectType()->priority <=> $a->getObjectType()->priority; - }); - - $setupId = \array_keys($this->setups)[0]; - if (isset($_GET['id'])) { - $setupId = intval($_GET['id']); - } - - if (!isset($this->setups[$setupId])) { - throw new IllegalLinkException(); - } - - $this->setup = $this->setups[$setupId]; - $this->method = $this->setup->getObjectType(); - \assert($this->method->getDefinition()->definitionName === 'com.woltlab.wcf.multifactor'); - - $this->processor = $this->method->getProcessor(); - } - - /** - * @inheritDoc - */ - protected function createForm() { - parent::createForm(); - - $this->processor->createAuthenticationForm($this->form, $this->setup); - } - - public function save() { - AbstractForm::save(); - - WCF::getDB()->beginTransaction(); - - $setup = $this->setup->lock(); - - $this->returnData = $this->processor->processAuthenticationForm($this->form, $setup); - - WCF::getDB()->commitTransaction(); - - WCF::getSession()->applyPendingUserChange($this->user); - - $this->saved(); - } - - /** - * @inheritDoc - */ - 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); - } - else { - HeaderUtil::redirect(LinkHandler::getInstance()->getLink()); - } - exit; - } - - /** - * @inheritDoc - */ - protected function setFormAction() { - $this->form->action(LinkHandler::getInstance()->getControllerLink(static::class, [ - 'object' => $this->setup, - 'url' => $this->redirectUrl, - ])); - } - - /** - * @inheritDoc - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign([ - 'setups' => $this->setups, - 'user' => $this->user, - 'userProfile' => UserProfileRuntimeCache::getInstance()->getObject($this->user->userID), - 'setup' => $this->setup, - 'redirectUrl' => $this->redirectUrl, - ]); - } +class MultifactorAuthenticationForm extends \wcf\form\MultifactorAuthenticationForm { + } diff --git a/wcfsetup/install/files/lib/form/MultifactorAuthenticationAbortForm.class.php b/wcfsetup/install/files/lib/form/MultifactorAuthenticationAbortForm.class.php index 5d16fa63e8..c018954507 100644 --- a/wcfsetup/install/files/lib/form/MultifactorAuthenticationAbortForm.class.php +++ b/wcfsetup/install/files/lib/form/MultifactorAuthenticationAbortForm.class.php @@ -79,7 +79,7 @@ class MultifactorAuthenticationAbortForm extends AbstractForm { // never be accessed via a direct link. // If we reach it nonetheless we simply redirect back to the authentication // form which contains the proper button to perform the submission. - HeaderUtil::redirect(LinkHandler::getInstance()->getControllerLink(MultifactorAuthenticationForm::class)); + HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MultifactorAuthentication')); exit; } }