-
Notifications
You must be signed in to change notification settings - Fork 640
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
Password#password_changed? returns true when transitioning crypto providers #721
Comments
Hi Paul, I'm glad to hear you're moving from SHA-512 to SCrypt. Good choice.
I agree.
Just for the record: I'd strongly recommend upgrading one major version at a time, and carefully reading the changelog for each. I'd also strongly discourage upgrading and changing one's hashing algorithm at the same time.
I wonder if Can you please start a draft PR with a test that reproduces the issue? |
Hmmm... To ActiveModel, I also use the attr_encrypted gem, which does do exactly that, but in that case it makes sense since it's generalized and the goal of the gem is to provider transparent encryption on any attribute. Good point about incremental changes. I could/should have left out the part about upgrading, since this is really about transitioning crypto providers. Yes I will submit a failing test. |
I've submitted the draft PR. |
Bump. Can this go forward? |
time, and responding promptly to feedback.
Current Behavior
Upgraded from authlogic 3 (to 5.1.0), added:
Now, whenever a user signs in with their existing password it gets rehashed using SCrypt, however the password_changed? method returns true, even though the password (what the user enters) has not really changed, only the crypted password and salt.
In my app, certain events are triggered if the password has changed. Specifically, a password changed notification. Now my users are confused.
I added this as a feature, because I guess it could be argued it's not a bug, per se.
Proposed Behavior
If the only change is rehashing the password, password_changed? should return false.
Proposed Solution
Password#password=
sets@password_changed = true
, so this would override that.Alternatively, a new accessor called password_transitioned could be added so the current behavior is unchanged, then I can include that in my conditions.
Personally, I can't think of a case where I'd expect password_changed? to return true unless the user actually changed their original password. If I want to know if the encrypted password changed, I could use the active record generated attribute method, so to me just plain password means the value that the user enters.
The text was updated successfully, but these errors were encountered: