Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -409,10 +409,11 @@ |
410 | 410 | &$text: string containing partially parsed text |
411 | 411 | &$this->mStripState: Parser's internal StripState object |
412 | 412 | |
413 | | -'LoginBadPass': a login attempt has failed with an invalid password. |
414 | | - No return data is accepted; this hook is for auditing only. |
| 413 | +'LoginAuthenticateAudit': a login attempt for a valid user account either succeeded or failed. |
| 414 | + No return data is accepted; this hook is for auditing only. |
415 | 415 | $user: the User object being authenticated against |
416 | 416 | $password: the password being submitted and found wanting |
| 417 | +$retval: a LoginForm class constant with authenticateUserData() return value (SUCCESS, WRONG_PASS, etc) |
417 | 418 | |
418 | 419 | 'LogPageValidTypes': action being logged. DEPRECATED: Use $wgLogTypes |
419 | 420 | &$type: array of strings |
Index: trunk/phase3/includes/SpecialUserlogin.php |
— | — | @@ -400,17 +400,18 @@ |
401 | 401 | // reset form; bot interfaces etc will probably just |
402 | 402 | // fail cleanly here. |
403 | 403 | // |
404 | | - return self::RESET_PASS; |
| 404 | + $retval = self::RESET_PASS; |
405 | 405 | } else { |
406 | | - wfRunHooks( 'LoginBadPass', array( $u, $this->mPassword ) ); |
407 | | - return '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS; |
| 406 | + $retval = '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS; |
408 | 407 | } |
409 | 408 | } else { |
410 | 409 | $wgAuth->updateUser( $u ); |
411 | 410 | $wgUser = $u; |
412 | 411 | |
413 | | - return self::SUCCESS; |
| 412 | + $retval = self::SUCCESS; |
414 | 413 | } |
| 414 | + wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $retval ) ); |
| 415 | + return $retval; |
415 | 416 | } |
416 | 417 | |
417 | 418 | function processLogin() { |
Index: trunk/phase3/includes/SpecialPreferences.php |
— | — | @@ -211,19 +211,23 @@ |
212 | 212 | |
213 | 213 | if ( '' != $this->mNewpass && $wgAuth->allowPasswordChange() ) { |
214 | 214 | if ( $this->mNewpass != $this->mRetypePass ) { |
| 215 | + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'badretype' ) ); |
215 | 216 | $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) ); |
216 | 217 | return; |
217 | 218 | } |
218 | 219 | |
219 | 220 | if (!$wgUser->checkPassword( $this->mOldpass )) { |
| 221 | + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'wrongpassword' ) ); |
220 | 222 | $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) ); |
221 | 223 | return; |
222 | 224 | } |
223 | 225 | |
224 | 226 | try { |
225 | 227 | $wgUser->setPassword( $this->mNewpass ); |
| 228 | + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'success' ) ); |
226 | 229 | $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; |
227 | 230 | } catch( PasswordError $e ) { |
| 231 | + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'error' ) ); |
228 | 232 | $this->mainPrefsForm( 'error', $e->getMessage() ); |
229 | 233 | return; |
230 | 234 | } |
— | — | @@ -321,6 +325,9 @@ |
322 | 326 | $wgUser->setCookies(); |
323 | 327 | $wgUser->saveSettings(); |
324 | 328 | } |
| 329 | + if( $oldadr != $newadr ) { |
| 330 | + wfRunHooks( "PrefsEmailAudit", array( $wgUser, $oldadr, $newadr ) ); |
| 331 | + } |
325 | 332 | } |
326 | 333 | |
327 | 334 | if( $needRedirect && $error === false ) { |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit.php |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | $wgHooks['UserCreateForm'][] = array( &$wgCaptcha, 'injectUserCreate' ); |
178 | 178 | $wgHooks['AbortNewAccount'][] = array( &$wgCaptcha, 'confirmUserCreate' ); |
179 | 179 | |
180 | | - $wgHooks['LoginBadPass'][] = array( &$wgCaptcha, 'triggerUserLogin' ); |
| 180 | + $wgHooks['LoginAuthenticateAudit'][] = array( &$wgCaptcha, 'triggerUserLogin' ); |
181 | 181 | $wgHooks['UserLoginForm'][] = array( &$wgCaptcha, 'injectUserLogin' ); |
182 | 182 | $wgHooks['AbortLogin'][] = array( &$wgCaptcha, 'confirmUserLogin' ); |
183 | 183 | } |
— | — | @@ -300,11 +300,12 @@ |
301 | 301 | * captcha display to prevent too many hits from the same place. |
302 | 302 | * @param User $user |
303 | 303 | * @param string $password |
| 304 | + * @param int $retval authentication return value |
304 | 305 | * @return bool true to keep running callbacks |
305 | 306 | */ |
306 | | - function triggerUserLogin( $user, $password ) { |
| 307 | + function triggerUserLogin( $user, $password, $retval ) { |
307 | 308 | global $wgCaptchaTriggers, $wgCaptchaBadLoginExpiration, $wgMemc; |
308 | | - if( $wgCaptchaTriggers['badlogin'] ) { |
| 309 | + if( $retval == LoginForm::WRONG_PASS && $wgCaptchaTriggers['badlogin'] ) { |
309 | 310 | $key = $this->badLoginKey(); |
310 | 311 | $count = $wgMemc->get( $key ); |
311 | 312 | if( !$count ) { |