mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fixed ConfirmedPasswordField validation for min password length
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62331 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1ba9c9a90a
commit
8b83c68f4c
@ -179,16 +179,16 @@ class ConfirmedPasswordField extends FormField {
|
|||||||
|
|
||||||
if(($this->minLength || $this->maxLength)) {
|
if(($this->minLength || $this->maxLength)) {
|
||||||
if($this->minLength && $this->maxLength) {
|
if($this->minLength && $this->maxLength) {
|
||||||
$limit = "{$this->minLength},{$this->maxLength}";
|
$limit = "{{$this->minLength},{$this->maxLength}}";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength);
|
||||||
} elseif($this->minLength) {
|
} elseif($this->minLength) {
|
||||||
$limit = "{$this->minLength}";
|
$limit = "{{$this->minLength}}.*";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength);
|
||||||
} elseif($this->maxLength) {
|
} elseif($this->maxLength) {
|
||||||
$limit = "0,{$this->maxLength}";
|
$limit = "{0,{$this->maxLength}}";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength);
|
||||||
}
|
}
|
||||||
$limitRegex = '/^.{' . $limit . '}$/';
|
$limitRegex = '/^.' . $limit . '$/';
|
||||||
$jsTests .= "
|
$jsTests .= "
|
||||||
if(passEl.value && !passEl.value.match({$limitRegex})) {
|
if(passEl.value && !passEl.value.match({$limitRegex})) {
|
||||||
validationError(confEl, \"{$errorMsg}\", \"error\");
|
validationError(confEl, \"{$errorMsg}\", \"error\");
|
||||||
@ -279,16 +279,16 @@ JS;
|
|||||||
// lengths
|
// lengths
|
||||||
if(($this->minLength || $this->maxLength)) {
|
if(($this->minLength || $this->maxLength)) {
|
||||||
if($this->minLength && $this->maxLength) {
|
if($this->minLength && $this->maxLength) {
|
||||||
$limit = "{$this->minLength},{$this->maxLength}";
|
$limit = "{{$this->minLength},{$this->maxLength}}";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength);
|
||||||
} elseif($this->minLength) {
|
} elseif($this->minLength) {
|
||||||
$limit = "{$this->minLength}";
|
$limit = "{{$this->minLength}}.*";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength);
|
||||||
} elseif($this->maxLength) {
|
} elseif($this->maxLength) {
|
||||||
$limit = "0,{$this->maxLength}";
|
$limit = "{0,{$this->maxLength}}";
|
||||||
$errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength);
|
$errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength);
|
||||||
}
|
}
|
||||||
$limitRegex = '/^.{' . $limit . '}$/';
|
$limitRegex = '/^.' . $limit . '$/';
|
||||||
if(!empty($value) && !preg_match($limitRegex,$value)) {
|
if(!empty($value) && !preg_match($limitRegex,$value)) {
|
||||||
$validator->validationError('Password', $errorMsg,
|
$validator->validationError('Password', $errorMsg,
|
||||||
"validation",
|
"validation",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user