From 17b1c776872577feed7839809f6593282e653af7 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 23 Jun 2022 03:17:31 +0200 Subject: [PATCH 1/2] Replace isLoggedIn --- OAuth2Client.php | 2 +- SpecialOAuth2Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OAuth2Client.php b/OAuth2Client.php index 7c42e9a..fbf7c56 100644 --- a/OAuth2Client.php +++ b/OAuth2Client.php @@ -21,7 +21,7 @@ class OAuth2ClientHooks { public static function onPersonalUrls( array &$personal_urls, Title $title ) { global $wgOAuth2Client, $wgUser, $wgRequest; - if( $wgUser->isLoggedIn() ) return true; + if( $wgUser->isRegistered() ) return true; # Due to bug 32276, if a user does not have read permissions, diff --git a/SpecialOAuth2Client.php b/SpecialOAuth2Client.php index e9a263d..0fbd497 100644 --- a/SpecialOAuth2Client.php +++ b/SpecialOAuth2Client.php @@ -140,7 +140,7 @@ private function _default(){ $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() ) { + if ( !$wgUser->isRegistered() ) { $wgOut->addWikiMsg( 'oauth2client-you-can-login-to-this-wiki-with-oauth2', $service_name ); $wgOut->addWikiMsg( 'oauth2client-login-with-oauth2', $this->getTitle( 'redirect' )->getPrefixedURL(), $service_name ); From b59257af8f24cc13068747dbda21ef3f6e901855 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 23 Jun 2022 03:40:47 +0200 Subject: [PATCH 2/2] Replace deprecated wgUser --- OAuth2Client.php | 6 ++++-- SpecialOAuth2Client.php | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/OAuth2Client.php b/OAuth2Client.php index fbf7c56..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->isRegistered() ) 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 0fbd497..be435a3 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->isRegistered() ) { + $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->getTitle( '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;