Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -506,7 +506,7 @@ |
507 | 507 | // Look for accounts we can match by password |
508 | 508 | foreach( $rows as $row ) { |
509 | 509 | $db = $row['dbName']; |
510 | | - if( $this->matchHash( $password, $row['localId'], $row['password'] ) ) { |
| 510 | + if( $this->matchHash( $password, $row['id'], $row['password'] ) ) { |
511 | 511 | wfDebugLog( 'CentralAuth', |
512 | 512 | "Attaching '$this->mName' on $db by password" ); |
513 | 513 | $this->attach( $db, 'password' ); |
— | — | @@ -606,6 +606,23 @@ |
607 | 607 | 'lu_dbname' => $dbname, |
608 | 608 | 'lu_name' => $this->mName ), |
609 | 609 | __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 | + } |
610 | 627 | wfDebugLog( 'CentralAuth', |
611 | 628 | "Attaching local user $this->mName@$dbname by '$method'" ); |
612 | 629 | |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | |
43 | 43 | $wgExtensionFunctions[] = 'wfSetupCentralAuth'; |
44 | 44 | $wgHooks['AuthPluginSetup'][] = 'wfSetupCentralAuthPlugin'; |
| 45 | +$wgHooks['AddNewAccount'][] = 'wfCentralAuthAddNewAccount'; |
45 | 46 | $wgHooks['PreferencesUserInformationPanel'][] = 'wfCentralAuthInformationPanel'; |
46 | 47 | |
47 | 48 | $wgGroupPermissions['steward']['centralauth-admin'] = true; |
— | — | @@ -114,3 +115,12 @@ |
115 | 116 | return true; |
116 | 117 | } |
117 | 118 | |
| 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 @@ |
219 | 219 | $attached = array(); |
220 | 220 | $unattached = array(); |
221 | 221 | $ok = $globalUser->storeAndMigrate( $passwords ); |
| 222 | + $this->clearWorkingPasswords(); |
222 | 223 | |
223 | 224 | if( $ok ) { |
224 | 225 | $wgOut->setPageTitle( wfMsg( 'centralauth-complete' ) ); |
— | — | @@ -225,7 +226,35 @@ |
226 | 227 | } else { |
227 | 228 | $wgOut->addHtml('boo it failed'); |
228 | 229 | } |
| 230 | + } |
| 231 | + |
| 232 | + function doCleanupMerge() { |
| 233 | + global $wgUser, $wgRequest, $wgOut, $wgDBname; |
| 234 | + $globalUser = new CentralAuthUser( $wgUser->getName() ); |
229 | 235 | |
| 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(); |
230 | 259 | } |
231 | 260 | |
232 | 261 | private function showWelcomeForm() { |