From f2ae7dcfe0b2f1b3beb5bc63916d79aeef195e67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 19 Nov 2020 11:42:02 +0100 Subject: [PATCH] Sort enabled MFA methods to the top in AccountSecurityPage --- .../files/lib/page/AccountSecurityPage.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; + }); } /** -- 2.20.1