Great module - thanks. It really simplifies the process and will definitely clear user confusion in the reset process.
I have been testing the module and found that the reset password on the altered form is saved to the Drupal database un the user table in clear text rather than hashed. This definitely caused problems for me and the user password was insecure and does not function.
To address this issue, I updated the simple_pass_reset_pass_reset_submit function in the module to:
// This logic copied from user_pass_reset().
$account = $form_state['user'];
$GLOBALS['user'] = $form_state['user'];
$account->pass = user_hash_password($account->pass);
user_login_finalize();
Looking for confirmation before generating and posting a patch. Is anyone else seeing this?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2367529.simple_pass_reset_login.patch | 1.86 KB | rszrama |
| #5 | password_not_hashed-2367529-5.patch | 562 bytes | heylookalive |
Comments
Comment #1
sebastien m. commentedHi Mark,
Can you explain step by step how to reproduce this issue ?
Thanks,
Comment #2
choribaquero80 commentedYour solution works great!
I had the same issue, I was having issues when any user reseted their password, after looking to the information with Devel I notice that the password was plain text (so a "123" password was stored as "123")
Thanks for the solution.
Comment #3
mxwitkowski commented@Sebastien - I encountered this issue whenever a user reset their password using the 'forgot password' process. When the user follows the link emailed to them and resets their password, it is stored as plaintext in the drupal database.
Comment #4
vali hutchison commentedYes, great improvement to the overall User experience - should be in Drupal Core! For the Drupal sites I manage, the single most common support request we get form users is related to confusion they have with the password reset process and this just makes much more sense.
I also had the same issue with password's not getting hashed - but interestingly, only on the live site server (using Nginx and PHP 5.6.4-1) whereas on my local dev environment (using Apache on Mac with PHP 5.5.14) with all the same code and same DB, it works fine.
When I added the
$account->pass = user_hash_password($account->pass);line from mxwitkowski's original post to the live site then it worked fine. Also worked fine on the dev site (ie it didn't disrupt it already working).Anyone got a clue as to why it doesn't work in some cases?
Comment #5
heylookalive commentedJust experienced this on an Acquia server, whereas was fine on my local vagrant box :/
Find attached a patch.
Comment #6
djschoone commentedJust found this issue. I think it is Critical, because passwords should never go unhashed into the database.
Tested the patch: works like a charm.
Comment #7
heylookalive commentedI'd agree with that!
Comment #8
rszrama commentedThe issue isn't that the new password isn't being hashed. It's that some module or another on your site is writing to the database on hook_user_login() as far as I can tell. By the time the code this patch is concerned with is invoked, the core submit handlers for this form have been invoked and saved the new hashed password. But somehow the user profile data is being re-saved, and because this module's submit handler sets the currently logged in user using outdated data from the $form_state, the global user account object has the unhashed password in it.
All that to say, the solution is to imitate user_login_submit() and load the user object afresh. There may be other unknown changes in it anyways. See the attached patch if you're curious what it looks like. I think the PHP difference some people pointed out was irrelevant (I tested in both PHP 5.5 and 5.6 and had hashed passwords) and suspect there's something else different between your site's environments that caused the unhashed password to be saved after the hashed one was.
Committed.
(Since this module itself wasn't saving the unhashed password, I demoted it to Major.)
Comment #10
heylookalive commentedWill give latest dev a go, thanks for this. Do you have a sense when you'll next do a stable release?
Comment #11
rszrama commentedJust rolled it! Waiting on d.o to package it up now. : )
Comment #12
rszrama commentedIt's up now. : )
Comment #13
vali hutchison commentedThanks @rszrama for the update - just updated to 7.x-1.5 and works fine now in both of the environments I'm using (Apache and Nginx) - passwords properly hashed.
Comment #14
rszrama commentedW00t w00t, that's what I like to hear. : D
Comment #15
heylookalive commentedExcellent! Thanks again :)
Comment #17
john_b commentedThanks for the module, and for the report and the fix.
I know this is old. However, not everyone applies non-security updates, so I suggesting marking a fixed update as a security update.
The risk is that one leaves the update and ends up with many hundreds of user name + email + plain text password sets in the users table, which is a real security risk. I have seen that happen.