-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb8e89c
commit cdfb384
Showing
15 changed files
with
136 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace CodedMonkey\Conductor\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
class ChangePasswordFormType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('currentPassword', PasswordType::class, [ | ||
'required' => true, | ||
]) | ||
->add('newPassword', NewPasswordType::class, [ | ||
'new_password' => true, | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace CodedMonkey\Conductor\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | ||
use Symfony\Component\OptionsResolver\Options; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\Validator\Constraints\Length; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
use Symfony\Component\Validator\Constraints\NotCompromisedPassword; | ||
use Symfony\Component\Validator\Constraints\PasswordStrength; | ||
|
||
class NewPasswordType extends AbstractType | ||
{ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'new_password' => false, | ||
'type' => PasswordType::class, | ||
'options' => [ | ||
'attr' => ['autocomplete' => 'new-password'], | ||
], | ||
'first_options' => function (Options $options): array { | ||
$label = $options['new_password'] ? 'New password' : 'Password'; | ||
|
||
return [ | ||
'constraints' => self::constraints(false), | ||
'label' => $label, | ||
]; | ||
}, | ||
'second_options' => function (Options $options): array { | ||
$label = $options['new_password'] ? 'Repeat new password' : 'Repeat password'; | ||
|
||
return [ | ||
'label' => $label, | ||
]; | ||
}, | ||
'invalid_message' => 'The password fields must match', | ||
]); | ||
} | ||
|
||
public function getParent(): string | ||
{ | ||
return RepeatedType::class; | ||
} | ||
|
||
public static function constraints(bool $nullable = true): array | ||
{ | ||
$constraints = [ | ||
new Length([ | ||
'min' => 8, | ||
'minMessage' => 'Your password should be at least {{ limit }} characters', | ||
'max' => 4096, // max length allowed by Symfony for security reasons | ||
]), | ||
new PasswordStrength(minScore: PasswordStrength::STRENGTH_WEAK), | ||
new NotCompromisedPassword(), | ||
]; | ||
|
||
if (!$nullable) { | ||
$constraints[] = new NotBlank([ | ||
'message' => 'Please enter a password', | ||
]); | ||
} | ||
|
||
return $constraints; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace CodedMonkey\Conductor\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class ResetPasswordFormType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('plainPassword', NewPasswordType::class, [ | ||
'new_password' => true, | ||
]); | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enter an email address: Enter an email address | ||
|
||
Please enter a password: Please enter a password | ||
The password fields must match: The password fields must match | ||
Your password should be at least {{ limit }} characters: Your password should be at least {{ limit }} characters |