Index: trunk/phase3/includes/Login.php |
— | — | @@ -176,6 +176,7 @@ |
177 | 177 | global $wgUser, $wgAuth; |
178 | 178 | |
179 | 179 | if ( '' == $this->mName ) { |
| 180 | + $this->mLoginResult = 'noname'; |
180 | 181 | return self::NO_NAME; |
181 | 182 | } |
182 | 183 | |
— | — | @@ -193,6 +194,7 @@ |
194 | 195 | } else if ( $throttleCount < $count ) { |
195 | 196 | $wgMemc->incr($throttleKey); |
196 | 197 | } else if ( $throttleCount >= $count ) { |
| 198 | + $this->mLoginResult = 'login-throttled'; |
197 | 199 | return self::THROTTLED; |
198 | 200 | } |
199 | 201 | } |
— | — | @@ -209,6 +211,16 @@ |
210 | 212 | } |
211 | 213 | |
212 | 214 | $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 | + } |
213 | 225 | |
214 | 226 | # TODO: Allow some magic here for invalid external names, e.g., let the |
215 | 227 | # user choose a different wiki name. |
— | — | @@ -217,12 +229,15 @@ |
218 | 230 | } |
219 | 231 | |
220 | 232 | # 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. |
222 | 234 | if ( $this->mUser->getID() == 0 ) { |
223 | 235 | if ( $this->canAutoCreate() == self::SUCCESS ) { |
224 | 236 | $isAutoCreated = true; |
225 | 237 | wfDebug( __METHOD__.": creating account\n" ); |
226 | | - $this->initUser( true ); |
| 238 | + $result = $this->initUser( true ); |
| 239 | + if( $result !== self::SUCCESS ){ |
| 240 | + return $result; |
| 241 | + }; |
227 | 242 | } else { |
228 | 243 | return $this->canAutoCreate(); |
229 | 244 | } |
— | — | @@ -232,9 +247,8 @@ |
233 | 248 | } |
234 | 249 | |
235 | 250 | # 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; |
239 | 253 | } |
240 | 254 | |
241 | 255 | if( !$this->mUser->checkPassword( $this->mPassword ) ) { |
— | — | @@ -264,7 +278,13 @@ |
265 | 279 | # etc will probably just fail cleanly here. |
266 | 280 | $retval = self::RESET_PASS; |
267 | 281 | } 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 | + } |
269 | 289 | } |
270 | 290 | } else { |
271 | 291 | $wgAuth->updateUser( $this->mUser ); |