authlogic
authlogic copied to clipboard
Transitioning password should not set password_changed? true
If a password is being transitioned to a new crypto provider, I would expect password_changed? to be falsey, but it is true. This draft PR adds a test to demonstrate it. If you change the definition of transition_password as follows, the test will pass:
def transition_password(attempted_password)
self.password = attempted_password
+ @password_changed = false
save(validate: false)
end
In password= @password_changed is set to true, so this just inverts that. Other possible solutions I've thought of:
- don't call password= in transition_password, instead call encrypt right there (and whatever else might be required
- set a new instance variable @password_transitioned which can be used in conditions like password_changed?
Bump on this @pduey , I'd be interested by this improvement!
Thank you for the contribution. I'm closing this due to inactivity. If you want to revive it, please re-open the pull request.