r24557 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24556‎ | r24557 | r24558 >
Date:06:54, 3 August 2007
Author:brion
Status:old
Tags:
Comment:
fix up the cleanup merge so it works; ui needs work
insert local records on account creation -- had been broken for autocreations by the schema change, and wasn't done in the proper hook for opt-in mode
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialMergeAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -506,7 +506,7 @@
507507 // Look for accounts we can match by password
508508 foreach( $rows as $row ) {
509509 $db = $row['dbName'];
510 - if( $this->matchHash( $password, $row['localId'], $row['password'] ) ) {
 510+ if( $this->matchHash( $password, $row['id'], $row['password'] ) ) {
511511 wfDebugLog( 'CentralAuth',
512512 "Attaching '$this->mName' on $db by password" );
513513 $this->attach( $db, 'password' );
@@ -606,6 +606,23 @@
607607 'lu_dbname' => $dbname,
608608 'lu_name' => $this->mName ),
609609 __METHOD__ );
 610+ if( $dbw->affectedRows() == 0 ) {
 611+ // *frowny face*
 612+
 613+ $dbw->insert( self::tableName( 'localuser' ),
 614+ array(
 615+ 'lu_dbname' => $dbname,
 616+ 'lu_name' => $this->mName ,
 617+ 'lu_attached' => 1,
 618+ 'lu_attached_timestamp' => $dbw->timestamp(),
 619+ 'lu_attached_method' => $method ),
 620+ __METHOD__,
 621+ array( 'IGNORE' ) );
 622+
 623+ if( $dbw->affectedRows() == 0 ) {
 624+ throw MWException( "Bogus attach" );
 625+ }
 626+ }
610627 wfDebugLog( 'CentralAuth',
611628 "Attaching local user $this->mName@$dbname by '$method'" );
612629
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -41,6 +41,7 @@
4242
4343 $wgExtensionFunctions[] = 'wfSetupCentralAuth';
4444 $wgHooks['AuthPluginSetup'][] = 'wfSetupCentralAuthPlugin';
 45+$wgHooks['AddNewAccount'][] = 'wfCentralAuthAddNewAccount';
4546 $wgHooks['PreferencesUserInformationPanel'][] = 'wfCentralAuthInformationPanel';
4647
4748 $wgGroupPermissions['steward']['centralauth-admin'] = true;
@@ -114,3 +115,12 @@
115116 return true;
116117 }
117118
 119+/**
 120+ * Make sure migration information in localuser table is populated
 121+ * on local account creation
 122+ */
 123+function wfCentralAuthAddNewAccount( $user ) {
 124+ $central = new CentralAuthUser( $user );
 125+ $central->lazyImportLocalNames();
 126+ $central->storeMigrationData( $wgDBname, array( $user->getName() ) );
 127+}
Index: trunk/extensions/CentralAuth/SpecialMergeAccount.php
@@ -218,6 +218,7 @@
219219 $attached = array();
220220 $unattached = array();
221221 $ok = $globalUser->storeAndMigrate( $passwords );
 222+ $this->clearWorkingPasswords();
222223
223224 if( $ok ) {
224225 $wgOut->setPageTitle( wfMsg( 'centralauth-complete' ) );
@@ -225,7 +226,35 @@
226227 } else {
227228 $wgOut->addHtml('boo it failed');
228229 }
 230+ }
 231+
 232+ function doCleanupMerge() {
 233+ global $wgUser, $wgRequest, $wgOut, $wgDBname;
 234+ $globalUser = new CentralAuthUser( $wgUser->getName() );
229235
 236+ if( !$globalUser->exists() ) {
 237+ throw new MWException( "User doesn't exist -- race condition?" );
 238+ }
 239+
 240+ $password = $wgRequest->getText( 'wpPassword' );
 241+
 242+ $home = false;
 243+ $attached = array();
 244+ $unattached = array();
 245+ $ok = $globalUser->attemptPasswordMigration( $password, $attached, $unattached );
 246+
 247+ if( $ok ) {
 248+ $wgOut->setPageTitle( wfMsg( 'centralauth-complete' ) );
 249+ $wgOut->addWikiText( wfMsg( 'centralauth-complete-text' ) );
 250+ } else {
 251+ if( empty( $attached ) ) {
 252+ $wgOut->addWikiText( "Couldn't confirm any -- bad pass" );
 253+ } else {
 254+ $wgOut->addWikiText( "Did some but incomplete still." );
 255+ }
 256+ $this->showCleanupForm();
 257+ }
 258+ $this->clearWorkingPasswords();
230259 }
231260
232261 private function showWelcomeForm() {

Status & tagging log