r56702 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56701‎ | r56702 | r56703 >
Date:13:53, 21 September 2009
Author:happy-melon
Status:reverted
Tags:
Comment:
Follow-up to r56684 - set message keys in Login.php, and readd the ExternalUser check that got lost somewhere in the branch merge.
Modified paths:
  • /trunk/phase3/includes/Login.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Login.php
@@ -176,6 +176,7 @@
177177 global $wgUser, $wgAuth;
178178
179179 if ( '' == $this->mName ) {
 180+ $this->mLoginResult = 'noname';
180181 return self::NO_NAME;
181182 }
182183
@@ -193,6 +194,7 @@
194195 } else if ( $throttleCount < $count ) {
195196 $wgMemc->incr($throttleKey);
196197 } else if ( $throttleCount >= $count ) {
 198+ $this->mLoginResult = 'login-throttled';
197199 return self::THROTTLED;
198200 }
199201 }
@@ -209,6 +211,16 @@
210212 }
211213
212214 $this->mExtUser = ExternalUser::newFromName( $this->mName );
 215+
 216+ # If the given username produces a valid ExternalUser, which is
 217+ # linked to an existing local user, use that, regardless of
 218+ # whether the username matches up.
 219+ if( $this->mExtUser ){
 220+ $user = $this->mExtUser->getLocalUser();
 221+ if( $user instanceof User ){
 222+ $this->mUser = $user;
 223+ }
 224+ }
213225
214226 # TODO: Allow some magic here for invalid external names, e.g., let the
215227 # user choose a different wiki name.
@@ -217,12 +229,15 @@
218230 }
219231
220232 # If the user doesn't exist in the local database, our only chance
221 - # is for an external auth plugin to autocreate the local user.
 233+ # is for an external auth plugin to autocreate the local user first.
222234 if ( $this->mUser->getID() == 0 ) {
223235 if ( $this->canAutoCreate() == self::SUCCESS ) {
224236 $isAutoCreated = true;
225237 wfDebug( __METHOD__.": creating account\n" );
226 - $this->initUser( true );
 238+ $result = $this->initUser( true );
 239+ if( $result !== self::SUCCESS ){
 240+ return $result;
 241+ };
227242 } else {
228243 return $this->canAutoCreate();
229244 }
@@ -232,9 +247,8 @@
233248 }
234249
235250 # Give general extensions, such as a captcha, a chance to abort logins
236 - $abort = self::ABORTED;
237 - if( !wfRunHooks( 'AbortLogin', array( $this->mUser, $this->mPassword, &$abort ) ) ) {
238 - return $abort;
 251+ if( !wfRunHooks( 'AbortLogin', array( $this->mUser, $this->mPassword, &$this->mLoginResult ) ) ) {
 252+ return self::ABORTED;
239253 }
240254
241255 if( !$this->mUser->checkPassword( $this->mPassword ) ) {
@@ -264,7 +278,13 @@
265279 # etc will probably just fail cleanly here.
266280 $retval = self::RESET_PASS;
267281 } else {
268 - $retval = ( $this->mPassword === '' ) ? self::EMPTY_PASS : self::WRONG_PASS;
 282+ if( $this->mPassword === '' ){
 283+ $retval = self::EMPTY_PASS;
 284+ $this->mLoginResult = 'wrongpasswordempty';
 285+ } else {
 286+ $retval = self::WRONG_PASS;
 287+ $this->mLoginResult = 'wrongpassword';
 288+ }
269289 }
270290 } else {
271291 $wgAuth->updateUser( $this->mUser );

Follow-up revisions

RevisionCommit summaryAuthorDate
r56937Revert broken rewrite of login system; totally broken....brion00:49, 26 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56684Merge in Login rewrite, second time lucky.happy-melon20:28, 20 September 2009

Status & tagging log