minlength: {@REGISTER_USERNAME_MIN_LENGTH},
maxlength: {@REGISTER_USERNAME_MAX_LENGTH}
});
+
+ require(['WoltLabSuite/Core/Ui/User/PasswordStrength'], function (PasswordStrength) {
+ new PasswordStrength(elById('{@$randomFieldNames[password]}'), {
+ relatedInputs: [
+ elById('{@$randomFieldNames[username]}'),
+ elById('{@$randomFieldNames[email]}')
+ ]
+ });
+ })
});
</script>
}
/**
- * Validates given password.
- *
- * @return array
+ * @deprecated 5.3 - Always returns isValid = true.
*/
public function validatePassword() {
- if (!UserRegistrationUtil::isSecurePassword($this->parameters['password'])) {
- return [
- 'isValid' => false,
- 'error' => 'notSecure'
- ];
- }
-
return [
'isValid' => true
];
*/
public static $minRegistrationTime = 10;
+ /**
+ * @var mixed[]
+ */
+ public $passwordStrengthVerdict = [];
+
/**
* @inheritDoc
*/
if (isset($_POST[$this->randomFieldNames['email']])) $this->email = StringUtil::trim($_POST[$this->randomFieldNames['email']]);
if (isset($_POST[$this->randomFieldNames['confirmEmail']])) $this->confirmEmail = StringUtil::trim($_POST[$this->randomFieldNames['confirmEmail']]);
if (isset($_POST[$this->randomFieldNames['password']])) $this->password = $_POST[$this->randomFieldNames['password']];
+ if (isset($_POST[$this->randomFieldNames['password'].'_passwordStrengthVerdict'])) {
+ try {
+ $this->passwordStrengthVerdict = JSON::decode($_POST[$this->randomFieldNames['password'].'_passwordStrengthVerdict']);
+ }
+ catch (SystemException $e) {
+ // ignore
+ }
+ }
if (isset($_POST[$this->randomFieldNames['confirmPassword']])) $this->confirmPassword = $_POST[$this->randomFieldNames['confirmPassword']];
$this->groupIDs = [];
parent::validatePassword($password, $confirmPassword);
// check security of the given password
- if (!UserRegistrationUtil::isSecurePassword($password)) {
+ if (($this->passwordStrengthVerdict['score'] ?? 4) < PASSWORD_MIN_SCORE) {
throw new UserInputException('password', 'notSecure');
}
}