Rename condition to `multifactorActive`
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 23 Nov 2020 17:05:51 +0000 (18:05 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Tue, 24 Nov 2020 10:59:15 +0000 (11:59 +0100)
wcfsetup/install/files/lib/system/condition/UserMultifactorCondition.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 6276c2465ca0d5bd11563ee06a8625149adffd87..7b9c63adcffe214870d6233db0ac8cd6a4f5edff 100644 (file)
@@ -9,7 +9,7 @@ use wcf\system\exception\UserInputException;
 use wcf\system\WCF;
 
 /**
- * Condition implementation if it is the user has an active second factor.
+ * Condition implementation for the multi-factor status of users.
  * 
  * @author     Joshua Ruesweg
  * @copyright  2001-2020 WoltLab GmbH
@@ -26,26 +26,26 @@ class UserMultifactorCondition extends AbstractSingleFieldCondition implements I
        protected $label = 'wcf.user.condition.multifactor';
        
        /**
-        * 1 if uses multifactor checkbox is checked
+        * 1 if multifactor active checkbox is checked
         * @var integer
         */
-       protected $usesMultifactor = 0;
+       protected $multifactorActive = 0;
        
        /**
-        * 1 if uses no multifactor checkbox is checked
+        * 1 if multifactor not active checkbox is checked
         * @var integer
         */
-       protected $usesNoMultifactor = 0;
+       protected $multifactorNotActive = 0;
        
        /**
         * @inheritDoc
         */
        public function getData() {
-               if ($this->usesMultifactor || $this->usesNoMultifactor) {
+               if ($this->multifactorActive || $this->multifactorNotActive) {
                        return [
-                               // if usesNoMultifactor is selected usesMultifactor is 0
-                               // otherwise usesNoMultifactor is 1
-                               'usesMultifactor' => $this->usesMultifactor
+                               // if multifactorNotActive is selected multifactorActive is 0
+                               // otherwise multifactorNotActive is 1
+                               'multifactorActive' => $this->multifactorActive
                        ];
                }
                
@@ -56,21 +56,21 @@ class UserMultifactorCondition extends AbstractSingleFieldCondition implements I
         * @inheritDoc
         */
        public function getFieldElement() {
-               $usesMultifactorLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.usesMultifactor');
-               $usesNoMultifactorLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.usesNoMultifactor');
-               $usesMultifactorChecked = '';
-               if ($this->usesMultifactor) {
-                       $usesMultifactorChecked = ' checked';
+               $multifactorActiveLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.multifactorActive');
+               $multifactorNotActiveLabel = WCF::getLanguage()->get('wcf.user.condition.multifactor.multifactorNotActive');
+               $multifactorActiveChecked = '';
+               if ($this->multifactorActive) {
+                       $multifactorActiveChecked = ' checked';
                }
                
-               $usesNoMultifactorChecked = '';
-               if ($this->usesNoMultifactor) {
-                       $usesNoMultifactorChecked = ' checked';
+               $multifactorNotActiveChecked = '';
+               if ($this->multifactorNotActive) {
+                       $multifactorNotActiveChecked = ' checked';
                }
                
                return <<<HTML
-<label><input type="checkbox" name="usesMultifactor" id="usesMultifactor"{$usesMultifactorChecked}> {$usesMultifactorLabel}</label>
-<label><input type="checkbox" name="usesNoMultifactor" id="usesNoMultifactor"{$usesNoMultifactorChecked}> {$usesNoMultifactorLabel}</label>
+<label><input type="checkbox" name="multifactorActive" id="multifactorActive"{$multifactorActiveChecked}> {$multifactorActiveLabel}</label>
+<label><input type="checkbox" name="multifactorNotActive" id="multifactorNotActive"{$multifactorNotActiveChecked}> {$multifactorNotActiveLabel}</label>
 HTML;
        }
        
@@ -78,33 +78,33 @@ HTML;
         * @inheritDoc
         */
        public function readFormParameters() {
-               if (isset($_POST['usesMultifactor'])) $this->usesMultifactor = 1;
-               if (isset($_POST['usesNoMultifactor'])) $this->usesNoMultifactor = 1;
+               if (isset($_POST['multifactorActive'])) $this->multifactorActive = 1;
+               if (isset($_POST['multifactorNotActive'])) $this->multifactorNotActive = 1;
        }
        
        /**
         * @inheritDoc
         */
        public function reset() {
-               $this->usesMultifactor = $this->usesNoMultifactor = 0;
+               $this->multifactorActive = $this->multifactorNotActive = 0;
        }
        
        /**
         * @inheritDoc
         */
        public function setData(Condition $condition) {
-               $this->usesMultifactor = $condition->usesMultifactor;
-               $this->usesNoMultifactor = !$condition->usesMultifactor;
+               $this->multifactorActive = $condition->multifactorActive;
+               $this->multifactorNotActive = !$condition->multifactorActive;
        }
        
        /**
         * @inheritDoc
         */
        public function validate() {
-               if ($this->usesMultifactor && $this->usesNoMultifactor) {
-                       $this->errorMessage = 'wcf.user.condition.multifactor.usesMultifactor.error.conflict';
+               if ($this->multifactorActive && $this->multifactorNotActive) {
+                       $this->errorMessage = 'wcf.user.condition.multifactor.multifactorActive.error.conflict';
                        
-                       throw new UserInputException('usesMultifactor', 'conflict');
+                       throw new UserInputException('multifactorActive', 'conflict');
                }
        }
        
@@ -112,7 +112,9 @@ HTML;
         * @inheritDoc
         */
        public function showContent(Condition $condition) {
-               return (($condition->usesMultifactor && WCF::getUser()->multifactorActive) || (!$condition->usesMultifactor && !WCF::getUser()->multifactorActive));
+               if (!WCF::getUser()->userID) return false;
+               
+               return $this->checkUser($condition, WCF::getUser());
        }
        
        /**
@@ -123,8 +125,8 @@ HTML;
                        throw new InvalidObjectArgument($objectList, UserList::class, 'Object list');
                }
                
-               if (isset($conditionData['usesMultifactor'])) {
-                       $objectList->getConditionBuilder()->add('user_table.multifactorActive = ?', [$conditionData['usesMultifactor']]);
+               if (isset($conditionData['multifactorActive'])) {
+                       $objectList->getConditionBuilder()->add('user_table.multifactorActive = ?', [$conditionData['multifactorActive']]);
                }
        }
        
@@ -132,7 +134,7 @@ HTML;
         * @inheritDoc
         */
        public function checkUser(Condition $condition, User $user) {
-               if ($condition->usesMultifactor !== null && $user->multifactorActive != $condition->usesMultifactor) {
+               if ($condition->multifactorActive !== null && $user->multifactorActive != $condition->multifactorActive) {
                        return false;
                }
                
index 37691187bf546494f2bd84df2d695e14466f1a78..6e0dce8a059972d2c60228d0a5742989c59dd414 100644 (file)
@@ -5093,9 +5093,9 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email}
                <item name="wcf.user.condition.mobileBrowser.usesMobileBrowser.error.conflict"><![CDATA[„Verwendet mobilen Browser“ und „Verwendet keinen mobilen Browser“ können nicht gleichzeitig ausgewählt werden.]]></item>
                <item name="wcf.user.condition.mobileBrowser.usesNoMobileBrowser"><![CDATA[Verwendet keinen mobilen Browser]]></item>
                <item name="wcf.user.condition.multifactor"><![CDATA[Mehrfaktor-Authentifizierung]]></item>
-               <item name="wcf.user.condition.multifactor.usesMultifactor"><![CDATA[Verwendet eine Mehrfaktor-Authentifizierung]]></item>
-               <item name="wcf.user.condition.multifactor.usesMultifactor.error.conflict"><![CDATA[„Verwendet die Mehrfaktor-Authentifizierung“ und „Verwendet keine Mehrfaktor-Authentifizierung“ können nicht gleichzeitig ausgewählt werden.]]></item>
-               <item name="wcf.user.condition.multifactor.usesNoMultifactor"><![CDATA[Verwendet keine Mehrfaktor-Authentifizierung]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorActive"><![CDATA[Mehrfaktor-Authentifizierung aktiv]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorActive.error.conflict"><![CDATA[„Mehrfaktor-Authentifizierung aktiv“ und „Mehrfaktor-Authentifizierung nicht aktiv“ können nicht gleichzeitig ausgewählt werden.]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorNotActive"><![CDATA[Mehrfaktor-Authentifizierung nicht aktiv]]></item>
                <item name="wcf.user.condition.notGroupIDs"><![CDATA[nicht in Benutzergruppen]]></item>
                <item name="wcf.user.condition.notGroupIDs.description"><![CDATA[Benutzer dürfen in keiner der ausgewählten Benutzergruppen Mitglied sein.]]></item>
                <item name="wcf.user.condition.notGroupIDs.error.groupIDsIntersection"><![CDATA[Die ausgewählten Benutzergruppen in „in Benutzergruppen“ und „nicht in Benutzergruppen“ sind widersprüchlich.]]></item>
index a5b83397028d411447774a0ee8f4b9c511eabfba..b78b2b0ba9066eca98fd01aea7f141fba3efb415 100644 (file)
@@ -5090,9 +5090,9 @@ Open the link below to access the user profile:
                <item name="wcf.user.condition.mobileBrowser.usesMobileBrowser.error.conflict"><![CDATA[You cannot simultaneously select “Uses mobile device” and “Uses desktop”.]]></item>
                <item name="wcf.user.condition.mobileBrowser.usesNoMobileBrowser"><![CDATA[Uses desktop]]></item>
                <item name="wcf.user.condition.multifactor"><![CDATA[Multi-Factor Authentication]]></item>
-               <item name="wcf.user.condition.multifactor.usesMultifactor"><![CDATA[Uses a Multi-Factor Authentication]]></item>
-               <item name="wcf.user.condition.multifactor.usesMultifactor.error.conflict"><![CDATA[You cannot simultaneously select “Uses a Multi-Factor Authentication” and “Uses no Multi-Factor Authentication”.]]></item>
-               <item name="wcf.user.condition.multifactor.usesNoMultifactor"><![CDATA[Uses no Multi-Factor Authentication]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorActive"><![CDATA[Multi-Factor Authentication active]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorActive.error.conflict"><![CDATA[You cannot simultaneously select “Multi-Factor Authentication active” and “Multi-Factor Authentication not active”.]]></item>
+               <item name="wcf.user.condition.multifactor.multifactorNotActive"><![CDATA[Multi-Factor Authentication not active]]></item>
                <item name="wcf.user.condition.notGroupIDs"><![CDATA[User Not in User Group(s)]]></item>
                <item name="wcf.user.condition.notGroupIDs.description"><![CDATA[User is not a member of the selected user group(s).]]></item>
                <item name="wcf.user.condition.notGroupIDs.error.groupIDsIntersection"><![CDATA[The selected user group(s) in “User in User Group(s)” and “User Not in User Group(s)” are conflicting.]]></item>