Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor OC\Server::getTwoFactorAuthManager #40127

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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;
Expand Down Expand Up @@ -524,7 +525,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);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/private/legacy/OC_JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;

class OC_JSON {
/**
* Check if the app is enabled, send json error msg if not
Expand All @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -785,7 +786,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();
}
Expand Down
Loading