diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index e7075bce47a06..32c767f2e7736 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -45,6 +45,7 @@ use OC\Authentication\Exceptions\PasswordLoginForbiddenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; +use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager; use OC\Hooks\Emitter; use OC\Hooks\PublicEmitter; use OC_User; @@ -514,7 +515,7 @@ protected function isTwoFactorEnforced($username) { $user = $users[0]; } // DI not possible due to cyclic dependencies :'-/ - return OC::$server->getTwoFactorAuthManager()->isTwoFactorAuthenticated($user); + return OC::$server->get(TwoFactorAuthManager::class)->isTwoFactorAuthenticated($user); } /** diff --git a/lib/private/legacy/OC_JSON.php b/lib/private/legacy/OC_JSON.php index b9cfb8210e09f..644fc1a59091c 100644 --- a/lib/private/legacy/OC_JSON.php +++ b/lib/private/legacy/OC_JSON.php @@ -27,6 +27,9 @@ * along with this program. If not, see * */ + +use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager; + class OC_JSON { /** * Check if the app is enabled, send json error msg if not @@ -48,7 +51,7 @@ public static function checkAppEnabled($app) { * @suppress PhanDeprecatedFunction */ public static function checkLoggedIn() { - $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager(); + $twoFactorAuthManger = \OC::$server->get(TwoFactorAuthManager::class); if (!\OC::$server->getUserSession()->isLoggedIn() || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { $l = \OC::$server->getL10N('lib'); diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 9d62c46137e61..2bf08396003c5 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -65,6 +65,7 @@ */ use bantu\IniGetWrapper\IniGetWrapper; +use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager; use OC\Files\SetupManager; use OCP\Files\Template\ITemplateManager; use OCP\IConfig; @@ -792,7 +793,7 @@ public static function checkLoggedIn() { exit(); } // Redirect to 2FA challenge selection if 2FA challenge was not solved yet - if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { + if (\OC::$server->get(TwoFactorAuthManager::class)->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge')); exit(); }