<div>
<div class="containerHeadline">
- <h3>{lang}wcf.user.security.multifactor.{$method->objectType}{/lang}</h3>
+ <h3>
+ {lang}wcf.user.security.multifactor.{$method->objectType}{/lang}
+
+ {if $enabledMultifactorMethods[$method->objectTypeID]|isset}
+ <span class="badge green">
+ {lang}wcf.user.security.multifactor.active{/lang}
+ </span>
+ {/if}
+ </h3>
{$method->getProcessor()->getStatusText($__wcf->user)}
</div>
use wcf\data\user\group\UserGroup;
use wcf\data\DatabaseObject;
use wcf\data\IUserContent;
+use wcf\data\object\type\ObjectType;
+use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\option\UserOption;
use wcf\system\cache\builder\UserOptionCacheBuilder;
use wcf\system\language\LanguageFactory;
return REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER;
}
+ /**
+ * Returns the multi factor methods the user set up.
+ *
+ * @return ObjectType[]
+ * @since 5.4
+ */
+ public function getEnabledMultifactorMethods(): array {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_user_multifactor
+ WHERE userID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$this->userID]);
+
+ $methods = [];
+ while ($row = $statement->fetchArray()) {
+ $methods[$row['setupID']] = ObjectTypeCache::getInstance()->getObjectType($row['objectTypeID']);
+ }
+
+ return $methods;
+ }
+
/**
* @inheritDoc
*/
*/
private $multifactorMethods;
+ /**
+ * @var int[]
+ */
+ private $enabledMultifactorMethods;
+
/**
* @inheritDoc
*/
});
$this->multifactorMethods = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.multifactor');
+ $this->enabledMultifactorMethods = array_flip(array_map(function (ObjectType $o) {
+ return $o->objectTypeID;
+ }, WCF::getUser()->getEnabledMultifactorMethods()));
}
/**
WCF::getTPL()->assign([
'activeSessions' => $this->activeSessions,
'multifactorMethods' => $this->multifactorMethods,
+ 'enabledMultifactorMethods' => $this->enabledMultifactorMethods,
]);
}