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
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
];
}
* @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;
}
* @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');
}
}
* @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());
}
/**
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']]);
}
}
* @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;
}
<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>
<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>