Skip to content

Commit

Permalink
chore: fix deprecation with wgUser and isLoggedIn (#2)
Browse files Browse the repository at this point in the history
* Replace isLoggedIn

* Replace deprecated wgUser

---------

Co-authored-by: Mo8it <mo8it@proton.me>
  • Loading branch information
Nymphxyz and mo8it authored Feb 25, 2024
1 parent ba9fe68 commit 5946b71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions OAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions SpecialOAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5946b71

Please sign in to comment.