r26320 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26319‎ | r26320 | r26321 >
Date:18:11, 2 October 2007
Author:brion
Status:old
Tags:
Comment:
Fix for unattached user's view of Special:MergeAccount when account is partially merged.
Patch by RotemLiss, from http://he.wikipedia.org/wiki/%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Rotemliss/CentralAuth#1
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialMergeAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/SpecialMergeAccount.php
@@ -56,6 +56,8 @@
5757 return $this->doInitialMerge();
5858 case "cleanup":
5959 return $this->doCleanupMerge();
 60+ case "attach":
 61+ return $this->doAttachMerge();
6062 case "remove":
6163 return $this->doUnattach();
6264 default:
@@ -65,7 +67,11 @@
6668
6769 $globalUser = new CentralAuthUser( $this->mUserName );
6870 if( $globalUser->exists() ) {
69 - $this->showCleanupForm();
 71+ if( $globalUser->isAttached() ) {
 72+ $this->showCleanupForm();
 73+ } else {
 74+ $this->showAttachForm();
 75+ }
7076 } else {
7177 $this->showWelcomeForm();
7278 }
@@ -274,6 +280,31 @@
275281 $this->showCleanupForm();
276282 }
277283
 284+ function doAttachMerge() {
 285+ global $wgUser, $wgRequest, $wgOut, $wgDBname, $wgCentralAuthDryRun;
 286+ $globalUser = new CentralAuthUser( $wgUser->getName() );
 287+
 288+ if( !$globalUser->exists() ) {
 289+ throw new MWException( "User doesn't exist -- race condition?" );
 290+ }
 291+
 292+ if( $wgCentralAuthDryRun ) {
 293+ return $this->dryRunError();
 294+ }
 295+ $password = $wgRequest->getText( 'wpPassword' );
 296+ if( $globalUser->authenticate( $password ) == 'ok' ) {
 297+ $globalUser->attach( $wgDBname, 'password' );
 298+ $wgOut->addWikiText( wfMsg( 'centralauth-attach-success' ) );
 299+ $this->showCleanupForm();
 300+ } else {
 301+ $wgOut->addHtml(
 302+ '<div class="errorbox">' .
 303+ wfMsg( 'wrongpassword' ) .
 304+ '</div>' .
 305+ $this->attachActionForm() );
 306+ }
 307+ }
 308+
278309 private function showWelcomeForm() {
279310 global $wgOut, $wgUser, $wgCentralAuthDryRun;
280311
@@ -305,6 +336,15 @@
306337 $this->showStatus( $merged, $remainder );
307338 }
308339
 340+ function showAttachForm() {
 341+ global $wgOut, $wgUser;
 342+ $globalUser = new CentralAuthUser( $wgUser->getName() );
 343+ $merged = $globalUser->listAttached();
 344+ $wgOut->addWikiText( wfMsg( 'centralauth-attach-list-attached', $this->mUserName ) );
 345+ $wgOut->addHtml( $this->listAttached( $merged ) );
 346+ $wgOut->addHtml( $this->attachActionForm() );
 347+ }
 348+
309349 function showStatus( $merged, $remainder ) {
310350 global $wgOut;
311351
@@ -483,6 +523,14 @@
484524 );
485525 }
486526
 527+ private function attachActionForm() {
 528+ return $this->passwordForm(
 529+ 'attach',
 530+ wfMsg( 'centralauth-attach-title' ),
 531+ wfMsg( 'centralauth-attach-text' ),
 532+ wfMsg( 'centralauth-attach-submit' ) );
 533+ }
 534+
487535 private function dryRunError() {
488536 global $wgOut;
489537 $wgOut->addWikiText( wfMsg( 'centralauth-disabled-dryrun' ) );
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -130,6 +130,13 @@
131131 'centralauth-merge-attempt' =>
132132 "'''Checking provided password against remaining unmerged accounts...'''",
133133
 134+ # When unattached, offer to attach...
 135+ 'centralauth-attach-list-attached' => 'The unified account named "$1" includes the following accounts:',
 136+ 'centralauth-attach-title' => 'Confirm account',
 137+ 'centralauth-attach-text' => 'This account has not yet been migrated to the unified account. If the global account is yours too, you can merge this account if you type the global account password:',
 138+ 'centralauth-attach-submit' => 'Migrate account',
 139+ 'centralauth-attach-success' => 'The account was migrated to the unified account.',
 140+
134141 // Administrator's console
135142 'centralauth' => 'Unified login administration',
136143 'centralauth-admin-manage' =>
@@ -653,6 +660,13 @@
654661
655662 'centralauth-merge-attempt' => "'''בודק האם הסיסמאות שניתנו תואמים לחשבונות הנותרים שלא מוזגו...'''",
656663
 664+ # When unattached, offer to attach...
 665+ 'centralauth-attach-list-attached' => 'החשבון הממוזג בשם המשתמש "$1" כולל את החשבונות הבאים:',
 666+ 'centralauth-attach-title' => 'אימות החשבון',
 667+ 'centralauth-attach-text' => 'חשבון זה לא נוסף עדיין לחשבון הממוזג. אם גם החשבון הממוזג שייך לכם, באפשרותכם למזג חשבון זה פשוט על־ידי הקלדת סיסמת החשבון הכללי:',
 668+ 'centralauth-attach-submit' => 'מיזוג החשבון',
 669+ 'centralauth-attach-success' => 'החשבון נוסף לחשבון הממוזג.',
 670+
657671 # Administrator's console
658672 'centralauth' => 'ניהול מיזוג החשבונות',
659673 'centralauth-admin-manage' => 'ניהול המידע על המשתמש',

Status & tagging log