From 96fde1385ae5d1a8c01dddd2bec872041aea4a91 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 26 Jan 2021 14:49:59 +0100 Subject: [PATCH] Add requireMultifactor property to user groups --- .../install/files/acp/templates/userGroupAdd.tpl | 11 +++++++++++ .../files/acp/update_com.woltlab.wcf_5.4_db.php | 5 +++++ .../files/lib/acp/form/UserGroupAddForm.class.php | 12 +++++++++++- .../files/lib/acp/form/UserGroupEditForm.class.php | 2 ++ .../files/lib/data/user/group/UserGroup.class.php | 2 ++ wcfsetup/install/lang/de.xml | 2 ++ wcfsetup/install/lang/en.xml | 2 ++ wcfsetup/setup/db/install.sql | 3 ++- 8 files changed, 37 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index a01205c89b..b095031ee0 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -143,6 +143,17 @@ {/if} + {if $action == 'add' || $group->groupType > 3} +
+
+
+ + + {lang}wcf.acp.group.requireMultifactor.description{/lang} +
+
+ {/if} + {if MODULE_TEAM_PAGE && ($action == 'add' || $group->groupType > 3)}
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php index 27d5e5110c..489c7416af 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php @@ -78,6 +78,11 @@ $tables = [ DefaultFalseBooleanDatabaseTableColumn::create("hasWebP"), ]), + PartialDatabaseTable::create('wcf1_user_group') + ->columns([ + DefaultFalseBooleanDatabaseTableColumn::create('requireMultifactor'), + ]), + DatabaseTable::create('wcf1_user_multifactor') ->columns([ ObjectIdDatabaseTableColumn::create('setupID'), diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php index 3bd79715eb..cf073030f8 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php @@ -89,6 +89,11 @@ class UserGroupAddForm extends AbstractOptionListForm */ protected $allowMention = 0; + /** + * @var int + */ + protected $requireMultifactor = 0; + /** * @inheritDoc */ @@ -128,6 +133,9 @@ class UserGroupAddForm extends AbstractOptionListForm if (isset($_POST['allowMention'])) { $this->allowMention = \intval($_POST['allowMention']); } + if (isset($_POST['requireMultifactor'])) { + $this->requireMultifactor = \intval($_POST['requireMultifactor']); + } } /** @@ -176,6 +184,7 @@ class UserGroupAddForm extends AbstractOptionListForm 'userOnlineMarking' => $this->userOnlineMarking, 'showOnTeamPage' => $this->showOnTeamPage, 'allowMention' => $this->allowMention ? 1 : 0, + 'requireMultifactor' => $this->requireMultifactor ? 1 : 0, ]), 'options' => $optionValues, ]; @@ -222,7 +231,7 @@ class UserGroupAddForm extends AbstractOptionListForm // reset values $this->groupName = ''; $this->userOnlineMarking = '%s'; - $this->allowMention = $this->priority = $this->showOnTeamPage = 0; + $this->requireMultifactor = $this->allowMention = $this->priority = $this->showOnTeamPage = 0; I18nHandler::getInstance()->reset(); } @@ -260,6 +269,7 @@ class UserGroupAddForm extends AbstractOptionListForm 'groupIsGuest' => false, 'isBlankForm' => empty($_POST), 'allowMention' => $this->allowMention, + 'requireMultifactor' => $this->requireMultifactor, ]); } diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php index fcbfac419c..d6c5db1034 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php @@ -117,6 +117,7 @@ class UserGroupEditForm extends UserGroupAddForm $this->userOnlineMarking = $this->group->userOnlineMarking; $this->showOnTeamPage = $this->group->showOnTeamPage; $this->allowMention = $this->group->allowMention; + $this->requireMultifactor = $this->group->requireMultifactor; } parent::readData(); @@ -194,6 +195,7 @@ class UserGroupEditForm extends UserGroupAddForm 'userOnlineMarking' => $this->userOnlineMarking, 'showOnTeamPage' => $this->showOnTeamPage, 'allowMention' => $this->allowMention, + 'requireMultifactor' => $this->requireMultifactor, ]), 'options' => $optionValues, ]); diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index 29af999e83..d130003eeb 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -32,6 +32,8 @@ use wcf\system\WCF; * should be shown on the team page, otherwise `0` * @property-read int $allowMention is `1` if the user group can be mentioned in messages, * otherwise `0` + * @property-read int $requireMultifactor is `1` if group members need to set up multi-factor + * authentcation, otherwise `0` */ class UserGroup extends DatabaseObject implements ITitledObject { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index af34bed040..9502be345b 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -906,6 +906,8 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index f02cff20b3..43a88615a9 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -883,6 +883,8 @@ ATTENTION: The messages listed above are greatly shortened. You can view details + + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 40829f4d68..3c87fa3b35 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -1571,7 +1571,8 @@ CREATE TABLE wcf1_user_group ( priority MEDIUMINT(8) NOT NULL DEFAULT 0, userOnlineMarking VARCHAR(255) NOT NULL DEFAULT '%s', showOnTeamPage TINYINT(1) NOT NULL DEFAULT 0, - allowMention TINYINT(1) NOT NULL DEFAULT 0 + allowMention TINYINT(1) NOT NULL DEFAULT 0, + requireMultifactor TINYINT(1) NOT NULL DEFAULT 0 ); DROP TABLE IF EXISTS wcf1_user_group_assignment; -- 2.20.1