From 333819804d9b8248fb8689a2681a7a8bcdd7e3b1 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Sun, 7 May 2023 20:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=BF=87=E6=97=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/IsekaiOIDCAuth.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/IsekaiOIDCAuth.php b/includes/IsekaiOIDCAuth.php index 6d82b99..b7a6884 100644 --- a/includes/IsekaiOIDCAuth.php +++ b/includes/IsekaiOIDCAuth.php @@ -72,7 +72,10 @@ class IsekaiOIDCAuth extends AbstractPrimaryAuthenticationProvider { global $wgIsekaiOIDC; $config = $wgIsekaiOIDC; - $oidc =self::getOpenIDConnectClient(); + $oidc = self::getOpenIDConnectClient(); + + $requestCtx = RequestContext::getMain(); + if ($oidc->authenticate()) { $accessToken = $oidc->getAccessToken(); $refreshToken = $oidc->getRefreshToken(); @@ -88,7 +91,7 @@ class IsekaiOIDCAuth extends AbstractPrimaryAuthenticationProvider { } $authManager = MediaWikiServices::getInstance()->getAuthManager(); - $request = RequestContext::getMain()->getRequest(); + $request = $requestCtx->getRequest(); $session = $request->getSession(); $session->clear('AuthManager::AutoCreateBlacklist'); // 防止缓存检测 @@ -251,7 +254,7 @@ class IsekaiOIDCAuth extends AbstractPrimaryAuthenticationProvider { $oidc->setRedirectURL( $redirectURL ); wfDebugLog( self::LOG_TAG, 'Redirect URL: ' . $redirectURL ); - if ( isset( $_REQUEST['forcelogin'] ) ) { + if ( isset( $_REQUEST['force'] ) || isset( $_REQUEST['forcelogin'] ) ) { $oidc->addAuthParam( [ 'prompt' => 'login' ] ); } if ( isset( $config['authparam'] ) &&