Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -590,25 +590,25 @@ |
591 | 591 | * @param array &$unattached on success, list of wikis which won't be auto-attached |
592 | 592 | * @param array &$methods on success, associative array of each wiki's attachment method |
593 | 593 | * @param array &$blocked true if the home wiki is blocked |
594 | | - * @return bool true if password matched current and home account |
| 594 | + * |
| 595 | + * @return Status object |
595 | 596 | */ |
596 | | - function migrationDryRun( $passwords, &$home, &$attached, &$unattached, &$methods, &$blocked ) { |
| 597 | + function migrationDryRun( $passwords, &$home, &$attached, &$unattached, &$methods ) { |
597 | 598 | $home = false; |
598 | 599 | $attached = array(); |
599 | 600 | $unattached = array(); |
600 | | - $blocked = false; |
601 | 601 | |
602 | 602 | // First, make sure we were given the current wiki's password. |
603 | 603 | $self = $this->localUserData( wfWikiID() ); |
604 | 604 | if( !$this->matchHashes( $passwords, $self['id'], $self['password'] ) ) { |
605 | 605 | wfDebugLog( 'CentralAuth', "dry run: failed self-password check" ); |
606 | | - return false; |
| 606 | + return Status::newFatal( 'wrongpassword' ); |
607 | 607 | } |
608 | 608 | |
609 | 609 | $migrationSet = $this->queryUnattached(); |
610 | 610 | if( empty( $migrationSet ) ) { |
611 | 611 | wfDebugLog( 'CentralAuth', 'dry run: no accounts to merge, failed migration' ); |
612 | | - return false; |
| 612 | + return Status::newFatal( 'centralauth-merge-no-accounts' ); |
613 | 613 | } |
614 | 614 | $home = $this->chooseHomeWiki( $migrationSet ); |
615 | 615 | $local = $migrationSet[$home]; |
— | — | @@ -616,8 +616,7 @@ |
617 | 617 | // If home account is blocked... |
618 | 618 | if( $local['blocked'] ) { |
619 | 619 | wfDebugLog( 'CentralAuth', "dry run: $home blocked, forbid migration" ); |
620 | | - $blocked = true; |
621 | | - return false; |
| 620 | + return Status::newFatal( 'centralauth-blocked-text' ); |
622 | 621 | } |
623 | 622 | |
624 | 623 | // And we need to match the home wiki before proceeding... |
— | — | @@ -625,7 +624,7 @@ |
626 | 625 | wfDebugLog( 'CentralAuth', "dry run: passed password match to home $home" ); |
627 | 626 | } else { |
628 | 627 | wfDebugLog( 'CentralAuth', "dry run: failed password match to home $home" ); |
629 | | - return false; |
| 628 | + return Status::newFatal( 'centralauth-merge-home-password' ); |
630 | 629 | } |
631 | 630 | |
632 | 631 | $this->mHomeWiki = $home; |
— | — | @@ -642,7 +641,7 @@ |
643 | 642 | sort( $unattached ); |
644 | 643 | ksort( $methods ); |
645 | 644 | |
646 | | - return true; |
| 645 | + return Status::newGood(); |
647 | 646 | } |
648 | 647 | |
649 | 648 | /** |
Index: trunk/extensions/CentralAuth/SpecialMergeAccount.php |
— | — | @@ -176,10 +176,9 @@ |
177 | 177 | $attached = array(); |
178 | 178 | $unattached = array(); |
179 | 179 | $methods = array(); |
180 | | - $blocked = false; |
181 | | - $ok = $globalUser->migrationDryRun( $passwords, $home, $attached, $unattached, $methods, $blocked ); |
| 180 | + $status = $globalUser->migrationDryRun( $passwords, $home, $attached, $unattached, $methods ); |
182 | 181 | |
183 | | - if( $ok ) { |
| 182 | + if( $status->isGood() ) { |
184 | 183 | // This is the global account or matched it |
185 | 184 | if( count( $unattached ) == 0 ) { |
186 | 185 | // Everything matched -- very convenient! |
— | — | @@ -195,25 +194,24 @@ |
196 | 195 | |
197 | 196 | $subAttached = array_diff( $attached, array( $home ) ); |
198 | 197 | $wgOut->addHtml( $this->step3ActionForm( $home, $subAttached, $methods ) ); |
| 198 | + } else { |
| 199 | + // Show error message from status |
| 200 | + $wgOut->addHtml( '<div class="errorbox" style="float:none;">' ); |
| 201 | + $wgOut->addWikiText( $status->getWikiText() ); |
| 202 | + $wgOut->addHtml( '</div>' ); |
199 | 203 | |
200 | | - } elseif( $home ) { |
201 | | - if( $blocked ) { |
202 | | - $wgOut->addWikiText( wfMsg( 'centralauth-blocked-text' ) ); |
203 | | - } else { |
204 | | - $wgOut->addWikiText( wfMsg( 'centralauth-merge-dryrun-home' ) ); |
| 204 | + // Show wiki list if required |
| 205 | + if ( $status->hasMessage( 'centralauth-blocked-text' ) |
| 206 | + || $status->hasMessage( 'centralauth-merge-home-password' ) ) |
| 207 | + { |
| 208 | + $out = '<h2>' . wfMsgHtml( 'centralauth-list-home-title' ) . '</h2>'; |
| 209 | + $out .= wfMsgExt( 'centralauth-list-home-dryrun', 'parse' ); |
| 210 | + $out .= $this->listAttached( array( $home ), array( $home => 'primary' ) ); |
| 211 | + $wgOut->addHtml( $out ); |
205 | 212 | } |
206 | | - $out = '<h2>' . wfMsgHtml( 'centralauth-list-home-title' ) . '</h2>'; |
207 | | - $out .= wfMsgExt( 'centralauth-list-home-dryrun', 'parse' ); |
208 | | - $out .= $this->listAttached( array( $home ), array( $home => 'primary' ) ); |
209 | | - $wgOut->addHtml( $out ); |
210 | | - } else { |
211 | | - // Didn't get your own password right? Laaaame! |
212 | | - $this->initSession(); |
213 | | - $wgOut->addHtml( |
214 | | - '<div class="errorbox">' . |
215 | | - wfMsg( 'wrongpassword' ) . |
216 | | - '</div>' . |
217 | | - $this->step1PasswordForm() ); |
| 213 | + |
| 214 | + // Show password box |
| 215 | + $wgOut->addHTML( $this->step1PasswordForm() ); |
218 | 216 | } |
219 | 217 | } |
220 | 218 | |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -51,6 +51,10 @@ |
52 | 52 | 'centralauth-merge-step3-title' => 'Create unified account', |
53 | 53 | 'centralauth-merge-step3-detail' => "You are ready to create your unified account, with the following wikis attached:", |
54 | 54 | 'centralauth-merge-step3-submit' => 'Unify accounts', |
| 55 | + 'centralauth-merge-no-accounts' => 'No accounts matching your name were found in the central account |
| 56 | +tracking table! The database must be corrupt.', |
| 57 | + 'centralauth-merge-home-password' => 'The home wiki for this account (listed below) has a different |
| 58 | +password to the one you entered. Please enter the password for the home wiki.', |
55 | 59 | |
56 | 60 | // Big text on completion |
57 | 61 | 'centralauth-complete' => 'Login unification complete!', |