Skip to content

Commit 1f2cfc4

Browse files
committed
Refactor OC\Server::getTwoFactorAuthManager
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
1 parent 613cd16 commit 1f2cfc4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/private/User/Session.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
4646
use OC\Authentication\Token\IProvider;
4747
use OC\Authentication\Token\IToken;
48+
use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
4849
use OC\Hooks\Emitter;
4950
use OC\Hooks\PublicEmitter;
5051
use OC_User;
@@ -514,7 +515,7 @@ protected function isTwoFactorEnforced($username) {
514515
$user = $users[0];
515516
}
516517
// DI not possible due to cyclic dependencies :'-/
517-
return OC::$server->getTwoFactorAuthManager()->isTwoFactorAuthenticated($user);
518+
return OC::$server->get(TwoFactorAuthManager::class)->isTwoFactorAuthenticated($user);
518519
}
519520

520521
/**

lib/private/legacy/OC_JSON.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
* along with this program. If not, see <http://www.gnu.org/licenses/>
2828
*
2929
*/
30+
31+
use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
32+
3033
class OC_JSON {
3134
/**
3235
* Check if the app is enabled, send json error msg if not
@@ -48,7 +51,7 @@ public static function checkAppEnabled($app) {
4851
* @suppress PhanDeprecatedFunction
4952
*/
5053
public static function checkLoggedIn() {
51-
$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
54+
$twoFactorAuthManger = \OC::$server->get(TwoFactorAuthManager::class);
5255
if (!\OC::$server->getUserSession()->isLoggedIn()
5356
|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
5457
$l = \OC::$server->getL10N('lib');

lib/private/legacy/OC_Util.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
*/
6666

6767
use bantu\IniGetWrapper\IniGetWrapper;
68+
use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
6869
use OC\Files\SetupManager;
6970
use OCP\Files\Template\ITemplateManager;
7071
use OCP\IConfig;
@@ -792,7 +793,7 @@ public static function checkLoggedIn() {
792793
exit();
793794
}
794795
// Redirect to 2FA challenge selection if 2FA challenge was not solved yet
795-
if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
796+
if (\OC::$server->get(TwoFactorAuthManager::class)->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
796797
header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge'));
797798
exit();
798799
}

0 commit comments

Comments
 (0)