<?php
namespace wcf\acp\form;
-
-use wcf\form\AbstractForm;
-use wcf\system\exception\PermissionDeniedException;
use wcf\system\request\LinkHandler;
-use wcf\system\WCF;
use wcf\util\HeaderUtil;
/**
* @package WoltLabSuite\Core\Acp\Form
* @since 5.4
*/
-class MultifactorAuthenticationAbortForm extends AbstractForm {
- const AVAILABLE_DURING_OFFLINE_MODE = true;
-
- /**
- * @inheritDoc
- */
- public $useTemplate = false;
-
- /**
- * @inheritDoc
- */
- public function readParameters() {
- parent::readParameters();
-
- if (WCF::getUser()->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;
- }
}
<?php
namespace wcf\acp\form;
-use wcf\data\object\type\ObjectType;
-use wcf\data\user\User;
-use wcf\form\AbstractForm;
-use wcf\form\AbstractFormBuilderForm;
-use wcf\system\application\ApplicationHandler;
-use wcf\system\cache\runtime\UserProfileRuntimeCache;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\request\LinkHandler;
-use wcf\system\user\multifactor\IMultifactorMethod;
-use wcf\system\user\multifactor\Setup;
-use wcf\system\WCF;
-use wcf\util\HeaderUtil;
/**
* Represents the multi-factor authentication form.
* @package WoltLabSuite\Core\Acp\Form
* @since 5.4
*/
-class MultifactorAuthenticationForm extends AbstractFormBuilderForm {
- const AVAILABLE_DURING_OFFLINE_MODE = true;
-
- /**
- * @inheritDoc
- */
- public $formAction = 'authenticate';
-
- /**
- * @var User
- */
- private $user;
-
- /**
- * @var Setup[]
- */
- private $setups;
-
- /**
- * @var ObjectType
- */
- private $method;
-
- /**
- * @var IMultifactorMethod
- */
- private $processor;
-
- /**
- * @var Setup
- */
- private $setup;
-
- /**
- * @var string
- */
- public $redirectUrl;
-
- /**
- * @inheritDoc
- */
- 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();
- }
-
- $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 {
+
}