Add ReauthenticationForm
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 1 Dec 2020 14:41:12 +0000 (15:41 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 7 Dec 2020 10:11:11 +0000 (11:11 +0100)
com.woltlab.wcf/page.xml
com.woltlab.wcf/templates/reauthentication.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/reauthentication.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/ReauthenticationForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/form/ReauthenticationForm.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 7f7d66e625d254c2e5e2a04851eef38c0d6cb6e7..36d384576a2c3adb0463b62c396b38fc5874df50 100644 (file)
@@ -866,6 +866,21 @@ E-Mail: [E-Mail-Adresse der verantwortlichen Stelle]</p><p><br></p><p>Verantwort
                                <title>Mehrfaktor-Authentifizierung deaktivieren</title>
                        </content>
                </page>
+               <page identifier="com.woltlab.wcf.Reauthentication">
+                       <pageType>system</pageType>
+                       <controller>wcf\form\ReauthenticationForm</controller>
+                       <name language="en">Re-authentication</name>
+                       <name language="de">Erneute Authentifizierung</name>
+                       <hasFixedParent>1</hasFixedParent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
+                       <availableDuringOfflineMode>1</availableDuringOfflineMode>
+                       <content language="en">
+                               <title>Re-authentication</title>
+                       </content>
+                       <content language="de">
+                               <title>Erneute Authentifizierung</title>
+                       </content>
+               </page>
        </import>
        <delete>
                <page identifier="com.woltlab.wcf.Mail"/>
diff --git a/com.woltlab.wcf/templates/reauthentication.tpl b/com.woltlab.wcf/templates/reauthentication.tpl
new file mode 100644 (file)
index 0000000..02b1ef7
--- /dev/null
@@ -0,0 +1,5 @@
+{include file='header' __disableAds=true}
+
+{@$form->getHtml()}
+
+{include file='footer' __disableAds=true}
diff --git a/wcfsetup/install/files/acp/templates/reauthentication.tpl b/wcfsetup/install/files/acp/templates/reauthentication.tpl
new file mode 100644 (file)
index 0000000..4a682a7
--- /dev/null
@@ -0,0 +1,11 @@
+{include file='header' pageTitle='wcf.user.reauthentication'}
+
+<header class="contentHeader">
+       <div class="contentHeaderTitle">
+               <h1 class="contentTitle">{lang}wcf.user.reauthentication{/lang}</h1>
+       </div>
+</header>
+
+{@$form->getHtml()}
+
+{include file='footer'}
diff --git a/wcfsetup/install/files/lib/acp/form/ReauthenticationForm.class.php b/wcfsetup/install/files/lib/acp/form/ReauthenticationForm.class.php
new file mode 100644 (file)
index 0000000..7670471
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+namespace wcf\acp\form;
+
+/**
+ * Represents the reauthentication form.
+ *
+ * @author     Tim Duesterhus
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\Acp\Form
+ * @since      5.4
+ */
+class ReauthenticationForm extends \wcf\form\ReauthenticationForm {
+
+}
diff --git a/wcfsetup/install/files/lib/form/ReauthenticationForm.class.php b/wcfsetup/install/files/lib/form/ReauthenticationForm.class.php
new file mode 100644 (file)
index 0000000..2de1145
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+namespace wcf\form;
+use wcf\form\AbstractFormBuilderForm;
+use wcf\system\application\ApplicationHandler;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\form\builder\field\user\UserPasswordField;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+use wcf\util\HeaderUtil;
+
+/**
+ * Represents the reauthentication form.
+ *
+ * @author     Tim Duesterhus
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\Form
+ * @since      5.4
+ */
+class ReauthenticationForm extends AbstractFormBuilderForm {
+       const AVAILABLE_DURING_OFFLINE_MODE = true;
+       
+       /**
+        * @inheritDoc
+        */
+       public $formAction = 'authenticate';
+       
+       /**
+        * @var string
+        */
+       public $redirectUrl;
+       
+       /**
+        * @inheritDoc
+        */
+       public function readParameters() {
+               parent::readParameters();
+               
+               if (!empty($_GET['url']) && ApplicationHandler::getInstance()->isInternalURL($_GET['url'])) {
+                       $this->redirectUrl = $_GET['url'];
+               }
+               else {
+                       throw new IllegalLinkException();
+               }
+               
+               if (!WCF::getSession()->needsReauthentication()) {
+                       $this->performRedirect();
+               }
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       protected function createForm() {
+               parent::createForm();
+               
+               $this->form->appendChild(
+                       UserPasswordField::create()
+                               ->required(),
+               );
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function save() {
+               AbstractForm::save();
+               
+               WCF::getSession()->registerReauthentication();
+               
+               $this->saved();
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function saved() {
+               AbstractForm::saved();
+               
+               $this->performRedirect();
+       }
+       
+       /**
+        * Returns to the redirectUrl.
+        */
+       protected function performRedirect() {
+               HeaderUtil::redirect($this->redirectUrl);
+               exit;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       protected function setFormAction() {
+               $this->form->action(LinkHandler::getInstance()->getControllerLink(static::class, [
+                       'url' => $this->redirectUrl,
+               ]));
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign([
+                       'redirectUrl' => $this->redirectUrl,
+               ]);
+       }
+}
index 6c455cbeaa616ae914d7071e826f87e40403ee18..f46ae2e50306dc34ec1c19f25244421bd3b8e510 100644 (file)
@@ -4746,6 +4746,7 @@ sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}
                <item name="wcf.user.status.banned"><![CDATA[Der Benutzer ist gesperrt.]]></item>
                <item name="wcf.user.status.isDisabled"><![CDATA[Der Benutzer ist nicht freigeschaltet.]]></item>
                <item name="wcf.user.status.blacklistMatches"><![CDATA[Der Benutzer wurde aufgrund eines Treffers in der Datenbank von „Stop Forum Spam“ automatisch deaktiviert (Übereinstimmungen: {implode glue=', ' from=$user->getBlacklistMatchesTitle() item=matchLabel}{$matchLabel}{/implode}).]]></item>
+               <item name="wcf.user.reauthentication"><![CDATA[Erneute Authentifizierung]]></item>
        </category>
        <category name="wcf.user.menu">
                <item name="wcf.user.menu.community"><![CDATA[Community]]></item>
index aa84ca6fb39372829623306360d6be2e318a97c7..e2e45e7190ab0cd23d13171d9b57b0e5a0e153d2 100644 (file)
@@ -4744,6 +4744,7 @@ not register with us.]]></item>
                <item name="wcf.user.status.banned"><![CDATA[The user has been banned.]]></item>
                <item name="wcf.user.status.isDisabled"><![CDATA[The user has not been approved yet.]]></item>
                <item name="wcf.user.status.blacklistMatches"><![CDATA[The user has been automatically disabled because of matches in the “Stop Forum Spam” database (Matches: {implode glue=', ' from=$user->getBlacklistMatchesTitle() item=matchLabel}{$matchLabel}{/implode}).]]></item>
+               <item name="wcf.user.reauthentication"><![CDATA[Re-authentication]]></item>
        </category>
        <category name="wcf.user.menu">
                <item name="wcf.user.menu.community"><![CDATA[Community]]></item>