Skip to content
Permalink
Browse files
[Data Objects] Password field: added optional minimum password length…
… setting
  • Loading branch information
brusch committed Jul 28, 2021
1 parent 43b0963 commit d5f01f8a9633d0473d66a8db3add94ba62331c8e
@@ -174,6 +174,12 @@ pimcore.object.classes.data.password = Class.create(pimcore.object.classes.data.
hideLabel: true,
value: t('width_explanation')
},
{
xtype: "numberfield",
fieldLabel: t("min_length"),
name: "minimumLength",
value: this.datax.minimumLength
},
algorithmsCombo,
salt,
saltCombo
@@ -193,6 +199,7 @@ pimcore.object.classes.data.password = Class.create(pimcore.object.classes.data.
Ext.apply(this.datax,
{
width: source.datax.width,
minimumLength: source.datax.minimumLength,
algorithm: source.datax.algorithm,
salt: source.datax.salt,
saltlocation: source.datax.saltlocation
@@ -604,6 +604,7 @@
"custom_login_background_image": "Custom Login Background Image",
"show_charcount": "Show Character Count",
"max_length": "Max Length",
"min_length": "Min Length",
"exclude_from_search_index": "Exclude from Backend Full-Text Search",
"media": "Media",
"encrypt_data": "Encrypt Data",
@@ -84,6 +84,11 @@ class Password extends Data implements ResourcePersistenceAwareInterface, QueryR
*/
public $saltlocation = '';

/**
* @var int|null
*/
public $minimumLength;

/**
* @return string|int
*/
@@ -107,6 +112,22 @@ public function setWidth($width)
return $this;
}

/**
* @return int|null
*/
public function getMinimumLength(): ?int
{
return $this->minimumLength;
}

/**
* @param int|null $minimumLength
*/
public function setMinimumLength(?int $minimumLength): void
{
$this->minimumLength = $minimumLength;
}

/**
* @param string $algorithm
*/
@@ -467,4 +488,13 @@ public function getPhpdocReturnType(): ?string
{
return 'string|null';
}

public function checkValidity($data, $omitMandatoryCheck = false, $params = [])
{
if($this->getMinimumLength() && strlen($data) < $this->getMinimumLength()) {
throw new Model\Element\ValidationException('Value in field [ ' . $this->getName() . ' ] is not at least ' . $this->getMinimumLength() . ' characters');
}

parent::checkValidity($data, $omitMandatoryCheck, $params);
}
}

0 comments on commit d5f01f8

Please sign in to comment.