]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
using config variable for minimum password length
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 10 Oct 2010 17:18:16 +0000 (17:18 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 10 Oct 2010 17:18:16 +0000 (17:18 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7047 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/users.php
engine/settings.example.php
install/ElggInstaller.php
install/languages/en.php

index c9add2541ae478ffe253748075a7b379d129604c..45499b27d59d0ce6c23115be13f2a1411bf1d5eb 100644 (file)
@@ -953,7 +953,9 @@ function validate_username($username) {
  * @throws RegistrationException on invalid
  */
 function validate_password($password) {
-       if (strlen($password) < 6) {
+       global $CONFIG;
+
+       if (strlen($password) < $CONFIG->min_password_length) {
                throw new RegistrationException(elgg_echo('registration:passwordtooshort'));
        }
 
index e6857e4c401067561c53be5f88a772f8f29b8b38..c503f0162b84adee389fd35991f45799406601eb 100644 (file)
@@ -110,4 +110,13 @@ $CONFIG->broken_mta = FALSE;
  *
  * @global bool $CONFIG->db_disable_query_cache
  */
-$CONFIG->db_disable_query_cache = FALSE;
\ No newline at end of file
+$CONFIG->db_disable_query_cache = FALSE;
+
+/**
+ * Minimum password length
+ *
+ * This value is used when validating a user's password during registration.
+ *
+ * @global int $CONFIG->min_password_length
+ */
+$CONFIG->min_password_length = 6;
\ No newline at end of file
index 19213908454a7860065b2bdaa01cf0d970132d4c..7d2e2355c26d23767db771c6d3230760fa33dc77 100644 (file)
@@ -382,6 +382,12 @@ class ElggInstaller {
                        } while (FALSE);  // PHP doesn't support breaking out of if statements
                }
 
+               // bit of a hack to get the password help to show right number of characters
+               global $CONFIG;
+               $lang = get_current_language();
+               $CONFIG->translations[$lang]['install:admin:help:password1'] =
+                               sprintf($CONFIG->translations[$lang]['install:admin:help:password1'], $CONFIG->min_password_length);
+
                $formVars = $this->makeFormSticky($formVars, $submissionVars);
 
                $this->render('admin', array('variables' => $formVars));
@@ -1287,6 +1293,12 @@ class ElggInstaller {
                        return FALSE;
                }
 
+               $minLength = get_config('min_password_length');
+               if (strlen($submissionVars['password1']) < $minLength) {
+                       register_error(elgg_echo('install:admin:password:tooshort'));
+                       return FALSE;
+               }
+
                // check that email address is email address
                if ($submissionVars['email'] && !is_email_address($submissionVars['email'])) {
                        $msg = sprintf(elgg_echo('install:error:emailaddress'), $submissionVars['email']);
index f474a8c7bfa166c80155d0e6378ed05f8e5797cf..d1c9d4a02e6ffa47bd7f291f1a6530399cbe5249 100644 (file)
@@ -102,11 +102,12 @@ If you are ready to proceed, click the Next button.",
        'install:admin:help:displayname' => 'The name that is displayed on the site for this account',
        'install:admin:help:email' => '',
        'install:admin:help:username' => 'Account username used for logging in',
-       'install:admin:help:password1' => 'Account password must be at least x characters long',
+       'install:admin:help:password1' => "Account password must be at least %u characters long",
        'install:admin:help:password2' => 'Retype password to confirm',
 
        'install:admin:password:mismatch' => 'Password must match.',
        'install:admin:password:empty' => 'Password cannot be empty.',
+       'install:admin:password:tooshort' => 'Your password was too short',
        'install:admin:cannot_create' => 'Unable to create an admin account.',
 
        'install:complete:instructions' => 'Your Elgg site is now ready to be used. Click the button below to be taken to your site.',