UserListener not being called when changing password
jerome2710 opened this issue · 0 comments
Environment
dev && prod
Packages
nucleos/user-bundle 2.1.0
symfony/framework-bundle v5.4.9
PHP version
PHP 8.1.6 (cli) (built: May 13 2022 23:21:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Xdebug v3.1.4, Copyright (c) 2002-2022, by Derick Rethans
Subject
When changing a password, either through the resetting routes or the nucleos:user:change-password
command, the password field in the database is not updated.
I have been debugging for quite some time now. The password is stored in an unmapped property plainPassword
by the SimpleUserManipulator and then persisted by the UserManager. The UserListener should then trigger the password hasher, creating a new password based on the plain password.
However, if only the unmapped plain password is changed, Doctrine will not fire the prePersist/preUpdate events. I verified this by adding Gedmo TimestampableEntity to my User object and updating updatedAt
when setPlainPassword()
is called. The password is now being re-hashed as it should.
Steps to reproduce
- Remove the password value for a user in the database
- Run
php bin/console nucleos:user:change-password
- Refresh your database, the password field is still empty
Expected results
The password should always be changed in the database based on the plain password, even if that's the only change happening.
Actual results
The password is not being updated, als the Doctrine events are not triggered.
Is this something structural or is my project configuration wrong / causing this issue?