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'] ) &&