Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions administrator/components/com_users/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@
default="0"
/>

<field
name="minimum_lowercase"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE"
description="COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE_DESC"
first="0"
last="98"
step="1"
default="0"
/>

</fieldset>

<fieldset
Expand Down
6 changes: 4 additions & 2 deletions administrator/language/en-GB/en-GB.com_admin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ COM_ADMIN_ZLIB_ENABLED="Zlib Enabled"
; Messages
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N="Password does not have enough digits. At least %s digits are required."
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N_1="Password does not have enough digits. At least 1 digit is required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N="Password does not have enough lower case characters. At least %s lower case characters are required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N_1="Password does not have enough lower case characters. At least 1 lower case character is required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N="Password does not have enough symbols. At least %s symbols are required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N_1="Password does not have enough symbols. At least 1 symbol is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough uppercase characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough uppercase characters. At least 1 upper case character is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough upper case characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough upper case characters. At least 1 upper case character is required."
COM_USERS_MSG_PASSWORD_TOO_LONG="Password is too long. Passwords must be less than 100 characters."
COM_USERS_MSG_PASSWORD_TOO_SHORT_N="Password is too short. Passwords must have at least %s characters."
COM_USERS_MSG_SPACES_IN_PASSWORD="Password must not have spaces at the beginning or end."
Expand Down
8 changes: 6 additions & 2 deletions administrator/language/en-GB/en-GB.com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ COM_USERS_CONFIG_FIELD_MAILTOADMIN_DESC="If set to Yes then a notification mail
COM_USERS_CONFIG_FIELD_MAILTOADMIN_LABEL="Send Mail to Administrators"
COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS="Minimum Integers"
COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS_DESC="Set the minimum number of integers that must be included in a password."
COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE="Minimum Lower Case"
COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE_DESC="Set the minimum number of lower case alphabetical characters required for a password."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change here? Label too?

COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH="Minimum Length"
COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH_DESC="Set the minimum length for a password."
COM_USERS_CONFIG_FIELD_MINIMUM_SYMBOLS="Minimum Symbols"
Expand Down Expand Up @@ -228,10 +230,12 @@ COM_USERS_MASS_MAIL="Mass Mail Users"
COM_USERS_MASS_MAIL_DESC="Mass Mail options."
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N="Password does not have enough digits. At least %s digits are required."
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N_1="Password does not have enough digits. At least 1 digit is required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N="Password does not have enough lower case characters. At least %s lower case characters are required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N_1="Password does not have enough lower case characters. At least 1 lower case character is required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N="Password does not have enough symbols. At least %s symbols are required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N_1="Password does not have enough symbols. At least 1 symbol is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough uppercase characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough uppercase characters. At least 1 upper case character is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough upper case characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough upper case characters. At least 1 upper case character is required."
COM_USERS_MSG_PASSWORD_TOO_LONG="Password is too long. Passwords must be less than 100 characters."
COM_USERS_MSG_PASSWORD_TOO_SHORT_N="Password is too short. Passwords must have at least %s characters."
COM_USERS_MSG_SPACES_IN_PASSWORD="Password must not have spaces at the beginning or end."
Expand Down
6 changes: 4 additions & 2 deletions language/en-GB/en-GB.com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ COM_USERS_MAIL_SEND_FAILURE_BODY="An error was encountered when sending the user
COM_USERS_MAIL_SEND_FAILURE_SUBJECT="Error sending email"
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N="Password does not have enough digits. At least %s digits are required."
COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N_1="Password does not have enough digits. At least 1 digit is required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N="Password does not have enough lower case characters. At least %s lower case characters are required."
COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N_1="Password does not have enough lower case characters. At least 1 lower case character is required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N="Password does not have enough symbols. At least %s symbols are required."
COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N_1="Password does not have enough symbols. At least 1 symbol is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough uppercase characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough uppercase characters. At least 1 upper case character is required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough upper case characters. At least %s upper case characters are required."
COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough upper case characters. At least 1 upper case character is required."
COM_USERS_MSG_PASSWORD_TOO_LONG="Password is too long. Passwords must be less than 100 characters."
COM_USERS_MSG_PASSWORD_TOO_SHORT_N="Password is too short. Passwords must have at least %s characters."
COM_USERS_MSG_SPACES_IN_PASSWORD="Password must not have spaces."
Expand Down
19 changes: 19 additions & 0 deletions libraries/src/Form/Rule/PasswordRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function test(\SimpleXMLElement $element, $value, $group = null, Registry
$minimumIntegers = isset($element['minimum_integers']) ? (int) $element['minimum_integers'] : 0;
$minimumSymbols = isset($element['minimum_symbols']) ? (int) $element['minimum_symbols'] : 0;
$minimumUppercase = isset($element['minimum_uppercase']) ? (int) $element['minimum_uppercase'] : 0;
$minimumLowercase = isset($element['minimum_lowercase']) ? (int) $element['minimum_lowercase'] : 0;

// If we have parameters from com_users, use those instead.
// Some of these may be empty for legacy reasons.
Expand All @@ -60,13 +61,15 @@ public function test(\SimpleXMLElement $element, $value, $group = null, Registry
$minimumIntegersp = $params->get('minimum_integers');
$minimumSymbolsp = $params->get('minimum_symbols');
$minimumUppercasep = $params->get('minimum_uppercase');
$minimumLowercasep = $params->get('minimum_lowercase');
$meterp = $params->get('meter');
$thresholdp = $params->get('threshold');

empty($minimumLengthp) ? : $minimumLength = (int) $minimumLengthp;
empty($minimumIntegersp) ? : $minimumIntegers = (int) $minimumIntegersp;
empty($minimumSymbolsp) ? : $minimumSymbols = (int) $minimumSymbolsp;
empty($minimumUppercasep) ? : $minimumUppercase = (int) $minimumUppercasep;
empty($minimumLowercasep) ? : $minimumLowercase = (int) $minimumLowercasep;
empty($meterp) ? : $meter = $meterp;
empty($thresholdp) ? : $threshold = $thresholdp;
}
Expand Down Expand Up @@ -154,6 +157,22 @@ public function test(\SimpleXMLElement $element, $value, $group = null, Registry
}
}

// Minimum number of lower case ASCII characters required
if (!empty($minimumLowercase))
{
$nLowercase = preg_match_all('/[a-z]/', $value, $umatch);

if ($nLowercase < $minimumLowercase)
{
\JFactory::getApplication()->enqueueMessage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be easy to namespace

\JText::plural('COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N', $minimumLowercase),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

'warning'
);

$validPassword = false;
}
}

// Minimum length option
if (!empty($minimumLength))
{
Expand Down