Sort enabled MFA methods to the top in AccountSecurityPage
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 Nov 2020 10:42:02 +0000 (11:42 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 Nov 2020 10:42:02 +0000 (11:42 +0100)
wcfsetup/install/files/lib/page/AccountSecurityPage.class.php

index 66cb59f04b5f97743bcd2e7fcc2ab3992cd471a4..a4a51986b0f8aaded4180fa0b11ea5d691f3c949 100644 (file)
@@ -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;
+               });
        }
        
        /**