jenkins-bot has submitted this change and it was merged.

Change subject: Implement OAuth hook to get userid from username
......................................................................


Implement OAuth hook to get userid from username

Implements hook from Ie17cacd68452ffea808d63b3d5b74078577c75be

Change-Id: Ib29dbb32e1e43c24416f2b2149f147248fea074b
---
M CentralAuth.php
M CentralAuthHooks.php
2 files changed, 25 insertions(+), 0 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CentralAuth.php b/CentralAuth.php
index c860ba0..3f08459 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -295,6 +295,7 @@
 // For OAuth
 $wgHooks['OAuthGetLocalUserFromCentralId'][] = 
'CentralAuthHooks::onOAuthGetLocalUserFromCentralId';
 $wgHooks['OAuthGetCentralIdFromLocalUser'][] = 
'CentralAuthHooks::onOAuthGetCentralIdFromLocalUser';
+$wgHooks['OAuthGetCentralIdFromUserName'][] = 
'CentralAuthHooks::onOAuthGetCentralIdFromUserName';
 $wgHooks['OAuthGetUserNamesFromCentralIds'][] = 
'CentralAuthHooks::onOAuthGetUserNamesFromCentralIds';
 
 $wgAvailableRights[] = 'centralauth-merge';
diff --git a/CentralAuthHooks.php b/CentralAuthHooks.php
index fa00734..efeec28 100644
--- a/CentralAuthHooks.php
+++ b/CentralAuthHooks.php
@@ -1491,4 +1491,28 @@
                $id = $centralUser->getId();
                return true;
        }
+
+       /**
+        * Get the id for the CentralAuth username. This hook should not be used
+        * to determine attachment, so as long as the CentralAuth account 
exists,
+        * we return the id.
+        * @param string $username the username
+        * @param string $wgMWOAuthCentralWiki
+        * @param int &$id the user_id of the matching name on the central wiki
+        * @param string $wgMWOAuthSharedUserSource the authoritative extension
+        */
+       public static function onOAuthGetCentralIdFromUserName( $username, 
$wgMWOAuthCentralWiki, &$id, $wgMWOAuthSharedUserSource ) {
+               if ( $wgMWOAuthSharedUserSource !== 'CentralAuth' ) {
+                       // We aren't supposed to handle this
+                       return true;
+               }
+               $centralUser = new CentralAuthUser( $username );
+               if ( $centralUser->getId() == 0 ) {
+                       $id = false;
+                       return false;
+               }
+
+               $id = $centralUser->getId();
+               return true;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/91331
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib29dbb32e1e43c24416f2b2149f147248fea074b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to