From: Jens Frank Date: Sun, 30 Jan 2005 19:39:11 +0000 (+0000) Subject: BUG#621 Require a minimum password length at account creation X-Git-Tag: 1.5.0alpha1~811 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=67c19f19e9a97297e609193087284e0ae89a5655;p=lhc%2Fweb%2Fwiklou.git BUG#621 Require a minimum password length at account creation --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 56652ef6b4..8eb112108a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -261,7 +261,7 @@ $wgMasterWaitTimeout = 10; # Sysop SQL queries # The sql user shouldn't have too many rights other the database, restrict -# it to SELECT only on 'cur' table for example +# it to SELECT only on 'page', 'revision' and 'text' tables for example # /** Dangerous if not configured properly. */ $wgAllowSysopQueries = false; @@ -1123,7 +1123,13 @@ $wgSearchForwardUrl = null; */ $wgNoFollowLinks = true; +/** + * Specifies the minimal length of a user password. If set to + * 0, empty passwords are allowed. + */ +$wgMinimalPasswordLength = 0; + } else { die(); } -?> \ No newline at end of file +?> diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 1cbd335aaf..58036a9bfd 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -172,7 +172,8 @@ class PreferencesForm { function savePreferences() { global $wgUser, $wgLang, $wgOut; global $wgEnableUserEmail, $wgEnableEmail; - global $wgEmailAuthentication; + global $wgEmailAuthentication, $wgMinimalPasswordLength; +; if ( '' != $this->mNewpass ) { if ( $this->mNewpass != $this->mRetypePass ) { @@ -180,6 +181,11 @@ class PreferencesForm { return; } + if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) { + $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) ); + return; + } + if (!$wgUser->checkPassword( $this->mOldpass )) { $this->mainPrefsForm( wfMsg( 'wrongpassword' ) ); return; diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 00a70d4cf0..ce96390ab2 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -189,15 +189,16 @@ class LoginForm { global $wgUser, $wgOut; global $wgMaxNameChars; global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP; + global $wgMinimalPasswordLength; if (!$wgUser->isAllowedToCreateAccount()) { $this->userNotPrivilegedMessage(); - return; + return false; } if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) { $this->mainLoginForm( wfMsg( 'badretype' ) ); - return; + return false; } $name = trim( $this->mName ); @@ -210,16 +211,21 @@ class LoginForm { ucFirst($name) != $u->getName() ) { $this->mainLoginForm( wfMsg( 'noname' ) ); - return; + return false; } if ( wfReadOnly() ) { $wgOut->readOnlyPage(); - return; + return false; } if ( 0 != $u->idForName() ) { $this->mainLoginForm( wfMsg( 'userexists' ) ); - return; + return false; + } + + if ( strlen( $this->mPassword ) < $wgMinimalPasswordLength ) { + $this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) ); + return false; } if ( $wgAccountCreationThrottle ) { @@ -230,7 +236,7 @@ class LoginForm { } if ( $value > $wgAccountCreationThrottle ) { $this->throttleHit( $wgAccountCreationThrottle ); - return; + return false; } } diff --git a/languages/Language.php b/languages/Language.php index d4f18866e0..a951a15e06 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1769,6 +1769,8 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\'); 'specialloguserlabel' => 'User: ', 'speciallogtitlelabel' => 'Title: ', +'passwordtooshort' => 'Your password is too short. It must have at least $1 characters.', + ); #-------------------------------------------------------------------------- diff --git a/languages/LanguageDe.php b/languages/LanguageDe.php index d8a93b29d5..51b647d5e5 100644 --- a/languages/LanguageDe.php +++ b/languages/LanguageDe.php @@ -1187,6 +1187,7 @@ Diskussions-Seite nicht, da schon eine mit dem neuen Titel existiert. Bitte glei # labels for User: and Title: on Special:Log pages 'specialloguserlabel' => 'Benutzer: ', 'speciallogtitlelabel' => 'Titel: ', +'passwordtooshort' => 'Ihr Passwort ist zu kurz. Es muss mindestens $1 Zeichen lang sein.', );