Skip to content

Commit

Permalink
EZP-30797: As an administrator, I want to configure a password expira…
Browse files Browse the repository at this point in the history
…tion for users
  • Loading branch information
adamwojs committed Sep 20, 2019
1 parent 20a650c commit 601ef58
Showing 2 changed files with 34 additions and 6 deletions.
10 changes: 10 additions & 0 deletions bundle/Resources/translations/ezrepoforms_content_type.en.xlf
Original file line number Diff line number Diff line change
@@ -476,6 +476,16 @@
<target>Password must contain at least one uppercase letter</target>
<note>key: field_definition.ezuser.require_at_least_one_upper_case_character</note>
</trans-unit>
<trans-unit id="b3a4113222154dde9c8d136f4bea80217129b739" resname="field_definition.ezuser.password_ttl">
<source>Days before passwords expire</source>
<target>Days before passwords expire</target>
<note>key: field_definition.ezuser.password_ttl</note>
</trans-unit>
<trans-unit id="cd2c70b2a3594f4de7adca0e84da6f106790ae8c" resname="field_definition.ezuser.password_ttl_warning">
<source>Days before a user is notified about expiration</source>
<target>Days before a user is notified about expiration</target>
<note>key: field_definition.ezuser.password_ttl_warning</note>
</trans-unit>
<trans-unit id="92d9243bb9fac540233dc376b41a3bcd41615ccc" resname="field_definition.field_group">
<source>Category</source>
<target>Category</target>
30 changes: 24 additions & 6 deletions lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php
Original file line number Diff line number Diff line change
@@ -78,32 +78,50 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
*/
public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data)
{
$propertyPathPrefix = 'validatorConfiguration[PasswordValueValidator]';
$validatorPropertyPathPrefix = 'validatorConfiguration[PasswordValueValidator]';

$fieldDefinitionForm->add('requireAtLeastOneUpperCaseCharacter', PasswordConstraintCheckboxType::class, [
'property_path' => $propertyPathPrefix . '[requireAtLeastOneUpperCaseCharacter]',
'property_path' => $validatorPropertyPathPrefix . '[requireAtLeastOneUpperCaseCharacter]',
]);

$fieldDefinitionForm->add('requireAtLeastOneLowerCaseCharacter', PasswordConstraintCheckboxType::class, [
'property_path' => $propertyPathPrefix . '[requireAtLeastOneLowerCaseCharacter]',
'property_path' => $validatorPropertyPathPrefix . '[requireAtLeastOneLowerCaseCharacter]',
]);

$fieldDefinitionForm->add('requireAtLeastOneNumericCharacter', PasswordConstraintCheckboxType::class, [
'property_path' => $propertyPathPrefix . '[requireAtLeastOneNumericCharacter]',
'property_path' => $validatorPropertyPathPrefix . '[requireAtLeastOneNumericCharacter]',
]);

$fieldDefinitionForm->add('requireAtLeastOneNonAlphanumericCharacter', PasswordConstraintCheckboxType::class, [
'property_path' => $propertyPathPrefix . '[requireAtLeastOneNonAlphanumericCharacter]',
'property_path' => $validatorPropertyPathPrefix . '[requireAtLeastOneNonAlphanumericCharacter]',
]);

$fieldDefinitionForm->add('minLength', IntegerType::class, [
'required' => false,
'property_path' => $propertyPathPrefix . '[minLength]',
'property_path' => $validatorPropertyPathPrefix . '[minLength]',
'label' => 'field_definition.ezuser.min_length',
'constraints' => [
new Range(['min' => 0, 'max' => 255]),
],
]);

$fieldDefinitionForm->add('passwordTTL', IntegerType::class, [
'required' => false,
'property_path' => 'fieldSettings[PasswordTTL]',
'label' => 'field_definition.ezuser.password_ttl',
'constraints' => [
new Range(['min' => 0, 'max' => null]),
],
]);

$fieldDefinitionForm->add('passwordTTLWarning', IntegerType::class, [
'required' => false,
'property_path' => 'fieldSettings[PasswordTTLWarning]',
'label' => 'field_definition.ezuser.password_ttl_warning',
'constraints' => [
new Range(['min' => 0, 'max' => null]),
],
]);
}

/**

0 comments on commit 601ef58

Please # to comment.