r83371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83370‎ | r83371 | r83372 >
Date:05:39, 6 March 2011
Author:jdpond
Status:resolved (Comments)
Tags:
Comment:
Fix and Enhance:
1. Fix - previously unresolved possible return value (ABORTED) added to switch
2. Allows a message to be returned when status "ABORTED" instead of just one of existing generic messages.
Modified paths:
  • /trunk/phase3/includes/api/ApiLogin.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesQqq.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -481,6 +481,7 @@
482482 'createaccount-text',
483483 'usernamehasherror',
484484 'login-throttled',
 485+ 'login-abort-generic',
485486 'loginlanguagelabel',
486487 'loginlanguagelinks',
487488 'suspicious-userlogout',
Index: trunk/phase3/includes/api/ApiLogin.php
@@ -140,6 +140,11 @@
141141 $result['result'] = 'Blocked';
142142 break;
143143
 144+ case LoginForm::ABORTED:
 145+ $result['result'] = 'Aborted';
 146+ $result['reason'] = $this->mAbortLoginErrorMsg;
 147+ break;
 148+
144149 default:
145150 ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$authRes}" );
146151 }
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -47,6 +47,7 @@
4848 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
4949 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
5050 var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS;
 51+ var $mAbortLoginErrorMsg = 'login-abort-generic';
5152
5253 private $mExtUser = null;
5354
@@ -527,7 +528,7 @@
528529
529530 // Give general extensions, such as a captcha, a chance to abort logins
530531 $abort = self::ABORTED;
531 - if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort ) ) ) {
 532+ if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) {
532533 return $abort;
533534 }
534535
@@ -707,6 +708,9 @@
708709 $this->mainLoginForm( wfMsgExt( 'login-userblocked',
709710 array( 'parsemag', 'escape' ), $this->mUsername ) );
710711 break;
 712+ case self::ABORTED:
 713+ $this->mainLoginForm( wfMsg( $this->mAbortLoginErrorMsg ) );
 714+ break;
711715 default:
712716 throw new MWException( 'Unhandled case value' );
713717 }
Index: trunk/phase3/languages/messages/MessagesQqq.php
@@ -720,6 +720,7 @@
721721 *Parameter $3 is a password (randomly generated).
722722 *Parameter $4 is a URL to the wiki',
723723 'login-throttled' => 'Error message shown at [[Special:UserLogin]] after 5 wrong passwords. The hardcoded waiting time is 300 seconds.',
 724+'login-abort-generic' => 'The generic unsuccessful login message used unless otherwise specified by hook writers',
724725
725726 # JavaScript password checks
726727 'password-strength' => 'Indicator of [[w:Password strength|password strength]] shown when entering a new password (during user registration or password reset).
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1153,6 +1153,7 @@
11541154 'usernamehasherror' => 'Username cannot contain hash characters',
11551155 'login-throttled' => 'You have made too many recent login attempts.
11561156 Please wait before trying again.',
 1157+'login-abort-generic' => 'Your login was unsuccessful - Aborted',
11571158 'loginlanguagelabel' => 'Language: $1',
11581159 'loginlanguagelinks' => '* Deutsch|de
11591160 * English|en

Sign-offs

UserFlagDate
Bawolfftested09:14, 6 March 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r83372Documentation updates for r83371jdpond06:07, 6 March 2011
r83376(follow-up: r83371) Fix variable name typo. $this to $loginForm.bawolff09:14, 6 March 2011

Comments

#Comment by Reedy (talk | contribs)   14:30, 6 March 2011
+				$result['reason'] =  $this->mAbortLoginErrorMsg;

Don't really think the direct member variable access is the best way to do this...

#Comment by Bawolff (talk | contribs)   17:01, 6 March 2011

Should add to the getPossibleErrors array in the api page (see discussion at Special:Code/MediaWiki/62402#c14672)

Status & tagging log