Enforce the multi-factor requirement in ACP
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jan 2021 14:58:25 +0000 (15:58 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jan 2021 14:58:25 +0000 (15:58 +0100)
wcfsetup/install/files/lib/system/WCFACP.class.php

index 8bfd76bbb6761e9de433cdc1b6f2ad715f0ab365..2ab1a294e20ee8f197e22d32b7a4fb589a96ab56 100644 (file)
@@ -17,6 +17,7 @@ use wcf\system\request\RouteHandler;
 use wcf\system\session\ACPSessionFactory;
 use wcf\system\session\SessionHandler;
 use wcf\system\template\ACPTemplateEngine;
+use wcf\system\user\multifactor\TMultifactorRequirementEnforcer;
 use wcf\util\FileUtil;
 use wcf\util\HeaderUtil;
 
@@ -200,6 +201,16 @@ class WCFACP extends WCF
                     exit;
                 }
 
+                // The autoloader is not available during the definition of `WCFACP`,
+                // thus we are unable to use the trait directly.
+                //
+                // Workaround this issue by using an anonymous class.
+                (new class {
+                    use TMultifactorRequirementEnforcer {
+                        enforceMultifactorAuthentication as public enforce;
+                    }
+                })->enforce();
+
                 // force debug mode if in ACP and authenticated
                 self::$overrideDebugMode = true;
             }