isDirty(), hasChanged() fails with Spring Security and MongoDB
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Expected Behavior
If there is NO any update property on the User object when it's saving, then the isDirty() function should work as expected. The **UserPasswordEncoderListener.class** should prevent any enconding password.
### Actual Behaviour
The isDirty() function is not working on the **UserPasswordEncoderListener.class**, every time I save a user object that has NO updates always return true, causing an already encoded password to be re-encoded and thereby breaking authentication.
**User Controller**
In the UserController, testing the isDirty function worked as expected.

**UserPasswordEncoderListener.class**
In the class doesn't work.

You can check the logs.

Any idea?
### Steps To Reproduce
_No response_
### Environment Information
- Mac OS X
- openjdk version "11.0.14.1" 2022-02-08 LTS
- OpenJDK Runtime Environment Corretto-11.0.14.10.1 (build 11.0.14.1+10-LTS)
- OpenJDK 64-Bit Server VM Corretto-11.0.14.10.1 (build 11.0.14.1+10-LTS, mixed mode)
- MongoDB
- Spring Security Core Plugin
### Example Application
_No response_
### Version
5.1.8
Contributor guide
Research direction
Start with UserPasswordEncoderListener.class and compare its isDirty() or hasChanged() behavior with the User Controller, where the report says the check works. Reproduce the save with Spring Security Core Plugin and MongoDB using the supplied environment details, then verify that an unchanged encoded password is not encoded again.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, mongodb, spring
- Domain
- authentication, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100