From: Rob Church Date: Tue, 17 Jul 2007 16:44:40 +0000 (+0000) Subject: * Clean up User::isValidPassword() X-Git-Tag: 1.31.0-rc.0~52047 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=e9aa9d20b982d4e6fd800fc0e5773c2b0874a3fc;p=lhc%2Fweb%2Fwiklou.git * Clean up User::isValidPassword() * Document 'isValidPassword' hook --- diff --git a/docs/hooks.txt b/docs/hooks.txt index ca30f73813..9ad6b9f4c8 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -464,6 +464,10 @@ after noinclude/includeonly/onlyinclude and other processing. &$text: string containing partially parsed text &$this->mStripState: Parser's internal StripState object +'isValidPassword': Override the result of User::isValidPassword() +$password: Desired password +&$result: Set this and return false to override the internal checks + '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 diff --git a/includes/User.php b/includes/User.php index d96cc6b196..b39f24f7f3 100644 --- a/includes/User.php +++ b/includes/User.php @@ -481,19 +481,23 @@ class User { } /** - * Is the input a valid password? + * Is the input a valid password for this user? * - * @param string $password + * @param string $password Desired password * @return bool */ function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang; $result = null; - if( !wfRunHooks( 'isValidPassword', array( $password, &$result ) ) ) return $result; - if ($result === false) return false; - return (strlen( $password ) >= $wgMinimalPasswordLength) && - ($wgContLang->lc( $password ) !== $wgContLang->lc( $this->mName )); + if( !wfRunHooks( 'isValidPassword', array( $password, &$result ) ) ) + return $result; + if( $result === false ) + return $false; + + // Password needs to be long enough, and can't be the same as the username + return strlen( $password ) >= $wgMinimalPasswordLength + && $wgContLang->lc( $password ) !== $wgContLang->lc( $this->mName ); } /**