From 68ee7d3bb4cbecc079441c6ca6d179cfeef78684 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Tim=20D=C3=BCsterhus?=
Date: Tue, 1 Dec 2020 15:41:12 +0100
Subject: [PATCH] Add ReauthenticationForm
---
com.woltlab.wcf/page.xml | 15 +++
.../templates/reauthentication.tpl | 5 +
.../files/acp/templates/reauthentication.tpl | 11 ++
.../acp/form/ReauthenticationForm.class.php | 15 +++
.../lib/form/ReauthenticationForm.class.php | 110 ++++++++++++++++++
wcfsetup/install/lang/de.xml | 1 +
wcfsetup/install/lang/en.xml | 1 +
7 files changed, 158 insertions(+)
create mode 100644 com.woltlab.wcf/templates/reauthentication.tpl
create mode 100644 wcfsetup/install/files/acp/templates/reauthentication.tpl
create mode 100644 wcfsetup/install/files/lib/acp/form/ReauthenticationForm.class.php
create mode 100644 wcfsetup/install/files/lib/form/ReauthenticationForm.class.php
diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml
index 7f7d66e625..36d384576a 100644
--- a/com.woltlab.wcf/page.xml
+++ b/com.woltlab.wcf/page.xml
@@ -866,6 +866,21 @@ E-Mail: [E-Mail-Adresse der verantwortlichen Stelle]
Verantwort
Mehrfaktor-Authentifizierung deaktivieren
+
+ system
+ wcf\form\ReauthenticationForm
+ Re-authentication
+ Erneute Authentifizierung
+ 1
+ 1
+ 1
+
+ Re-authentication
+
+
+ Erneute Authentifizierung
+
+
diff --git a/com.woltlab.wcf/templates/reauthentication.tpl b/com.woltlab.wcf/templates/reauthentication.tpl
new file mode 100644
index 0000000000..02b1ef733d
--- /dev/null
+++ b/com.woltlab.wcf/templates/reauthentication.tpl
@@ -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
index 0000000000..4a682a73b0
--- /dev/null
+++ b/wcfsetup/install/files/acp/templates/reauthentication.tpl
@@ -0,0 +1,11 @@
+{include file='header' pageTitle='wcf.user.reauthentication'}
+
+
+
+{@$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
index 0000000000..7670471ad7
--- /dev/null
+++ b/wcfsetup/install/files/lib/acp/form/ReauthenticationForm.class.php
@@ -0,0 +1,15 @@
+
+ * @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
index 0000000000..2de11450e4
--- /dev/null
+++ b/wcfsetup/install/files/lib/form/ReauthenticationForm.class.php
@@ -0,0 +1,110 @@
+
+ * @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,
+ ]);
+ }
+}
diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml
index 6c455cbeaa..f46ae2e503 100644
--- a/wcfsetup/install/lang/de.xml
+++ b/wcfsetup/install/lang/de.xml
@@ -4746,6 +4746,7 @@ sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}
- getBlacklistMatchesTitle() item=matchLabel}{$matchLabel}{/implode}).]]>
+
diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml
index aa84ca6fb3..e2e45e7190 100644
--- a/wcfsetup/install/lang/en.xml
+++ b/wcfsetup/install/lang/en.xml
@@ -4744,6 +4744,7 @@ not register with us.]]>
- getBlacklistMatchesTitle() item=matchLabel}{$matchLabel}{/implode}).]]>
+
--
2.20.1