BUG#621 Require a minimum password length at account creation
authorJens Frank <jeluf@users.mediawiki.org>
Sun, 30 Jan 2005 19:39:11 +0000 (19:39 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sun, 30 Jan 2005 19:39:11 +0000 (19:39 +0000)
includes/DefaultSettings.php
includes/SpecialPreferences.php
includes/SpecialUserlogin.php
languages/Language.php
languages/LanguageDe.php

index 56652ef..8eb1121 100644 (file)
@@ -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
+?>
index 1cbd335..58036a9 100644 (file)
@@ -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;
index 00a70d4..ce96390 100644 (file)
@@ -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;
                        }
                }
 
index d4f1886..a951a15 100644 (file)
@@ -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.',
+
 );
 
 #--------------------------------------------------------------------------
index d8a93b2..51b647d 100644 (file)
@@ -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.',
 
 );