diff --git a/OAuth2Client.php b/OAuth2Client.php index 7c42e9a..859ee19 100644 --- a/OAuth2Client.php +++ b/OAuth2Client.php @@ -20,8 +20,10 @@ class OAuth2ClientHooks { public static function onPersonalUrls( array &$personal_urls, Title $title ) { - global $wgOAuth2Client, $wgUser, $wgRequest; - if( $wgUser->isLoggedIn() ) return true; + global $wgOAuth2Client, $wgRequest; + + $user = RequestContext::getMain()->getUser(); + if( $user->isRegistered() ) return true; # Due to bug 32276, if a user does not have read permissions, diff --git a/SpecialOAuth2Client.php b/SpecialOAuth2Client.php index f29e1f9..a94cab9 100644 --- a/SpecialOAuth2Client.php +++ b/SpecialOAuth2Client.php @@ -136,11 +136,13 @@ private function _handleCallback(){ } private function _default(){ - global $wgOAuth2Client, $wgOut, $wgUser, $wgScriptPath, $wgExtensionAssetsPath; + global $wgOAuth2Client, $wgOut, $wgScriptPath, $wgExtensionAssetsPath; + $service_name = ( isset( $wgOAuth2Client['configuration']['service_name'] ) && 0 < strlen( $wgOAuth2Client['configuration']['service_name'] ) ? $wgOAuth2Client['configuration']['service_name'] : 'OAuth2' ); $wgOut->setPagetitle( wfMessage( 'oauth2client-login-header', $service_name)->text() ); - if ( !$wgUser->isLoggedIn() ) { + $user = RequestContext::getMain()->getUser(); + if ( !$user->isRegistered() ) { $wgOut->addWikiMsg( 'oauth2client-you-can-login-to-this-wiki-with-oauth2', $service_name ); $wgOut->addWikiMsg( 'oauth2client-login-with-oauth2', $this->getPageTitle( 'redirect' )->getPrefixedURL(), $service_name ); @@ -197,8 +199,7 @@ protected function _userHandling( $response ) { $user->setCookies(); $this->getContext()->setUser( $user ); $user->saveSettings(); - global $wgUser; - $wgUser = $user; + RequestContext::getMain()->setUser( $user ); $sessionUser = User::newFromSession($this->getRequest()); $sessionUser->load(); return $user;