Closed jhawthorn closed 6 years ago
Hmm, not sure if we want this. Before the api key only changes if the password really changed, now it always changes the api even when setting the same password again.
Even when using password_changed?
it will happen even when setting the same password (and setting the same password has to be done intentionally).
> user.encrypted_password_changed? #=> false
> user.password = "test123"
> user.encrypted_password_changed? #=> true
> user.save!
> user.encrypted_password_changed? #=> false
> user.password = "test123"
> user.encrypted_password_changed? #=> true
However, encrypted_password_changed?
doesn't become true if the new password was blank?
(like with ""
). So we should check that before updating.
Updated and added spec for assigning empty password
Instead of resetting it when saving a new password. This avoids adding an ActiveRecord callback which in turn needs to use the
_changed?
api (which has changing in Rails 5.1).This avoids a warning on Rails 5.1