From 50c317ff981dd11b2125b997a5128225fd68df7b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 8 May 2007 18:31:32 +0000 Subject: [PATCH] Tweak audit hooks --- docs/hooks.txt | 5 +++-- includes/SpecialPreferences.php | 7 +++++++ includes/SpecialUserlogin.php | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 6f66b06279..62e4c46daf 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -409,10 +409,11 @@ after noinclude/includeonly/onlyinclude and other processing. &$text: string containing partially parsed text &$this->mStripState: Parser's internal StripState object -'LoginBadPass': a login attempt has failed with an invalid password. - No return data is accepted; this hook is for auditing only. +'LoginAuthenticateAudit': a login attempt for a valid user account either succeeded or failed. + No return data is accepted; this hook is for auditing only. $user: the User object being authenticated against $password: the password being submitted and found wanting +$retval: a LoginForm class constant with authenticateUserData() return value (SUCCESS, WRONG_PASS, etc) 'LogPageValidTypes': action being logged. DEPRECATED: Use $wgLogTypes &$type: array of strings diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 660ede9fda..05605d3808 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -211,19 +211,23 @@ class PreferencesForm { if ( '' != $this->mNewpass && $wgAuth->allowPasswordChange() ) { if ( $this->mNewpass != $this->mRetypePass ) { + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'badretype' ) ); $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) ); return; } if (!$wgUser->checkPassword( $this->mOldpass )) { + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'wrongpassword' ) ); $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) ); return; } try { $wgUser->setPassword( $this->mNewpass ); + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'success' ) ); $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; } catch( PasswordError $e ) { + wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'error' ) ); $this->mainPrefsForm( 'error', $e->getMessage() ); return; } @@ -321,6 +325,9 @@ class PreferencesForm { $wgUser->setCookies(); $wgUser->saveSettings(); } + if( $oldadr != $newadr ) { + wfRunHooks( "PrefsEmailAudit", array( $wgUser, $oldadr, $newadr ) ); + } } if( $needRedirect && $error === false ) { diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 26196b891e..3bd77285ce 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -400,17 +400,18 @@ class LoginForm { // reset form; bot interfaces etc will probably just // fail cleanly here. // - return self::RESET_PASS; + $retval = self::RESET_PASS; } else { - wfRunHooks( 'LoginBadPass', array( $u, $this->mPassword ) ); - return '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS; + $retval = '' == $this->mPassword ? self::EMPTY_PASS : self::WRONG_PASS; } } else { $wgAuth->updateUser( $u ); $wgUser = $u; - return self::SUCCESS; + $retval = self::SUCCESS; } + wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $retval ) ); + return $retval; } function processLogin() { -- 2.20.1