From: Tim Düsterhus Date: Thu, 19 Nov 2020 10:42:02 +0000 (+0100) Subject: Sort enabled MFA methods to the top in AccountSecurityPage X-Git-Tag: 5.4.0_Alpha_1~555^2~44 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f2ae7dcfe0b2f1b3beb5bc63916d79aeef195e67;p=GitHub%2FWoltLab%2FWCF.git Sort enabled MFA methods to the top in AccountSecurityPage --- diff --git a/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php b/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php index 66cb59f04b..a4a51986b0 100644 --- a/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php +++ b/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php @@ -52,14 +52,16 @@ class AccountSecurityPage extends AbstractPage { $this->multifactorMethods = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.multifactor'); - usort($this->multifactorMethods, function (ObjectType $a, ObjectType $b) { - return $b->priority <=> $a->priority; - }); - $setups = Setup::getAllForUser(WCF::getUser()); foreach ($setups as $setup) { $this->enabledMultifactorMethods[$setup->getObjectType()->objectTypeID] = $setup; } + + usort($this->multifactorMethods, function (ObjectType $a, ObjectType $b) { + $aEnabled = isset($this->enabledMultifactorMethods[$a->objectTypeID]) ? 1 : 0; + $bEnabled = isset($this->enabledMultifactorMethods[$b->objectTypeID]) ? 1 : 0; + return $bEnabled <=> $aEnabled ?: $b->priority <=> $a->priority; + }); } /**