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
4 changes: 2 additions & 2 deletions administrator/language/en-GB/com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ COM_USERS_CONFIG_FIELD_FRONTEND_USERPARAMS_LABEL="Frontend User Parameters"
COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL="Guest User Group"
COM_USERS_CONFIG_FIELD_MAILBODY_SUFFIX_LABEL="Mailbody Suffix"
COM_USERS_CONFIG_FIELD_MAILTOADMIN_LABEL="Send Mail to Administrators"
COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS="Minimum Integers"
COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS="Minimum Digits"
COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE="Minimum Lower Case"
COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH="Minimum Length"
COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH="Minimum Characters"
COM_USERS_CONFIG_FIELD_MINIMUM_SYMBOLS="Minimum Symbols"
COM_USERS_CONFIG_FIELD_MINIMUM_UPPERCASE="Minimum Upper Case"
COM_USERS_CONFIG_FIELD_NEW_USER_TYPE_LABEL="New User Registration Group"
Expand Down
6 changes: 6 additions & 0 deletions administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ JFIELD_PASSWORD_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough up
JFIELD_PASSWORD_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough upper case characters. At least 1 upper case character is required."
JFIELD_PASSWORD_NOTE_DESC="%1 symbol(s), %2 uppercase letter(s), %3 lowercase letter(s), %4 number(s)"
JFIELD_PASSWORD_NOTE_LBL="Password must contain:"
JFIELD_PASSWORD_RULES_CHARACTERS="Characters: %d"
JFIELD_PASSWORD_RULES_DIGITS="Digits: %d"
JFIELD_PASSWORD_RULES_LOWERCASE="Lower Case: %d"
JFIELD_PASSWORD_RULES_MINIMUM_REQUIREMENTS="<strong>Minimum Requirements</strong> — %s"
JFIELD_PASSWORD_RULES_SYMBOLS="Symbols: %d"
JFIELD_PASSWORD_RULES_UPPERCASE="Upper Case: %d"
JFIELD_PASSWORD_SPACES_IN_PASSWORD="Password must not have spaces at the beginning or end."
JFIELD_PASSWORD_TOO_LONG="Password is too long. Passwords must be less than 100 characters."
JFIELD_PASSWORD_TOO_SHORT_N="Password is too short. Passwords must have at least %s characters."
Expand Down
2 changes: 2 additions & 0 deletions components/com_users/forms/registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
name="password1"
type="password"
label="COM_USERS_PROFILE_PASSWORD1_LABEL"
description="JFIELD_PASSWORD_RULES_MINIMUM_REQUIREMENTS"
required="true"
autocomplete="new-password"
class="validate-password"
field="password1"
size="30"
validate="password"
strengthmeter="true"
rules="true"
force="on"
filter="raw"
/>
Expand Down
6 changes: 6 additions & 0 deletions language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ JFIELD_PASSWORD_NOT_ENOUGH_UPPERCASE_LETTERS_N="Password does not have enough up
JFIELD_PASSWORD_NOT_ENOUGH_UPPERCASE_LETTERS_N_1="Password does not have enough upper case characters. At least 1 upper case character is required."
JFIELD_PASSWORD_NOTE_DESC="%1 symbol(s), %2 uppercase letter(s), %3 lowercase letter(s), %4 number(s)"
JFIELD_PASSWORD_NOTE_LBL="Password must contain:"
JFIELD_PASSWORD_RULES_CHARACTERS="Characters: %d"
JFIELD_PASSWORD_RULES_DIGITS="Digits: %d"
JFIELD_PASSWORD_RULES_LOWERCASE="Lower Case: %d"
JFIELD_PASSWORD_RULES_MINIMUM_REQUIREMENTS="<strong>Minimum Requirements</strong> — %s"
JFIELD_PASSWORD_RULES_SYMBOLS="Symbols: %d"
JFIELD_PASSWORD_RULES_UPPERCASE="Upper Case: %d"
JFIELD_PASSWORD_SPACES_IN_PASSWORD="Password must not have spaces at the beginning or end."
JFIELD_PASSWORD_TOO_LONG="Password is too long. Passwords must be less than 100 characters."
JFIELD_PASSWORD_TOO_SHORT_N="Password is too short. Passwords must have at least %s characters."
Expand Down
37 changes: 36 additions & 1 deletion layouts/joomla/form/field/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate elements.
* @var boolean $required Is this field required?
* @var boolean $rules Are the rules to be displayed?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
Expand Down Expand Up @@ -91,12 +92,46 @@
$dataAttribute,
);

if ($rules && !empty($description))
{
$requirements = [];

if ($minLength)
{
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_CHARACTERS', $minLength);
}

if ($minIntegers)
{
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_DIGITS', $minIntegers);
}

if ($minSymbols)
{
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_SYMBOLS', $minSymbols);
}

if ($minUppercase)
{
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_UPPERCASE', $minUppercase);
}

if ($minLowercase)
{
$requirements[] = Text::sprintf('JFIELD_PASSWORD_RULES_LOWERCASE', $minLowercase);
}
}
?>
<?php if (!empty($description)) : ?>
<div id="<?php echo $name . '-desc'; ?>" class="small text-muted">
<?php echo htmlspecialchars(Text::_($description), ENT_COMPAT, 'UTF-8'); ?>
<?php if ($rules) : ?>
<?php echo Text::sprintf($description, implode(', ', $requirements)); ?>
<?php else : ?>
<?php echo Text::_($description); ?>
<?php endif; ?>
</div>
<?php endif; ?>

<div class="password-group">
<div class="input-group">
<input
Expand Down
19 changes: 11 additions & 8 deletions libraries/src/Form/Field/PasswordField.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
$this->meter = ($meter === 'true' || $meter === 'on' || $meter === '1');
$force = (string) $this->element['forcePassword'];
$this->force = (($force === 'true' || $force === 'on' || $force === '1') && $this->meter === true);
$rules = (string) $this->element['rules'];
$this->rules = (($rules === 'true' || $rules === 'on' || $rules === '1') && $this->meter === true);

// Set some initial values
$this->minLength = 12;
Expand Down Expand Up @@ -199,15 +201,16 @@ protected function getLayoutData()

// Initialize some field attributes.
$extraData = array(
'maxLength' => $this->maxLength,
'meter' => $this->meter,
'threshold' => $this->threshold,
'minLength' => $this->minLength,
'minIntegers' => $this->minIntegers,
'maxLength' => $this->maxLength,
'meter' => $this->meter,
'threshold' => $this->threshold,
'minLength' => $this->minLength,
'minIntegers' => $this->minIntegers,
'minSymbols' => $this->minSymbols,
'minUppercase' => $this->minUppercase,
'minLowercase' => $this->minLowercase,
'forcePassword' => $this->force,
'minUppercase' => $this->minUppercase,
'minLowercase' => $this->minLowercase,
'forcePassword' => $this->force,
'rules' => $this->rules,
);

return array_merge($data, $extraData);
Expand Down