-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Skip password hashing on empty password #49459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
$form = $this->factory | ||
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $user) | ||
->add('plainPassword', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use ::class even if some other test cases don't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -37,6 +37,10 @@ public function __construct( | ||
|
||
public function registerPassword(FormEvent $event) | ||
{ | ||
if ('' === $event->getData()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we account for null
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
89b37a1
to
b4aa3ea
Compare
Thank you @Seb33300. |
When using the new
hash_property_path
option to hash password submitted by forms, we should skip hashing if the submitted password is empty.Because empty passwords are not allowed and saving an empty password hash will prevent the user to login his account:
symfony/src/Symfony/Component/Security/Http/EventListener/CheckCredentialsListener.php
Lines 59 to 62 in 8c19af2
Because a common use case when creating a user profile form is to ignore the "new password" input if it's left blank.