If a user clicks the one-time login link (from new password request) and someone is logged into the drupal site on the browser they're using, they get a message that says "You have already used this one-time login link. It is not necessary to use this link to login anymore. You are already logged in.". The reality is that we don't know whether they've used the link, just that *someone* is logged in.
How to recreate: Get a one-time login link. Log in with your username and password (or with a different account's username and password). Click the link.
What I expect: To get a relevant message (You're already logged in... Someone is already logged in...)
What happened instead: You get the error message "You have already used this one-time login link. It is not necessary to use this link to login anymore. You are already logged in." Note that you get this message regardless of whether the link was used, and regardless of what user was logged in.
The attached patch fine-tunes this behavior with better error message and it differentiates the message (whether the logged-in user is the user who clicked the link or not).
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | password_reset_patch-545230-d6-17.patch | 1.79 KB | albert volkman |
| #11 | password_reset_patch_545230_06.patch | 1.69 KB | rfay |
| #10 | password_reset_patch_545230_05.patch | 1.68 KB | rfay |
| #7 | 545230.patch | 1.41 KB | robloach |
| #5 | password_reset_patch_545230_04.patch | 1.19 KB | rfay |
Comments
Comment #1
rfay@greggles was kind enough to take a look at this. Here is a rerolled patch with his suggestions, which are formatting, comment style, etc.
Comment #2
rfayIt's my understanding that patches like this have to make it into D7 first, so here it is for D7.
Comment #3
rfayHere are screenshots of the behavior:
Note that the "other user logged in" behavior of the existing code is probably the most pernicious... It says "you are already logged in" and you most certainly are not. But the "this user logged in" behavior is also bad. On Drupal sites people are often logged in without understanding that they are, and they get all confused when they use a link and it says they've already used it, etc.
--------------------------------------------------------

--------------------------------------------------------
--------------------------------------------------------

Comment #4
rfayPer conversation with @Bohjan, I changed the text for when a user is already logged. It seems we don't really need to tell them they didn't need the one-time-link. We just need to get them to change their password so they know how to use the system. The new text for when a user uses the link but the same user is already logged in:
You are logged in as username. (link to user/xxx/edit) Change your password.
Here's the resultant screenshot for the case where the user was already logged in.

Comment #5
rfayOops - forgot the patch for #5. Here it is.
Comment #6
Bojhan commentedLooks good, I expect it will take some time before this gets a second review - with code freeze and all
Comment #7
robloachRefactored a bit, fixed some coding convention and added some little documentation, the functionality is the same. Even though the use case is a bit strange, I think its need is valid.
Another thing we could do is use:
...But that doesn't really look pretty.
Comment #8
moshe weitzman commentedbig improvement. i think thats pretty (informative).
Comment #9
webchickThese t() strings are a bit inconsistent with others in core:
a) We should switch the quotes so that the string is encased in single quotes and the link href in double quotes.
b) Elsewhere, url() strings are passed in with descriptive @ placeholders that describe where they're going to go, rather than ! placeholders called a generic "link". For example, @block-admin, @cron, etc.
c) The braces in
user/{$user->uid}/editis rather ugly. Does it work without? If not, let's use concatenation here instead as it helps with the readability.Finally, that second string doesn't quite feel right. I like that it's plain-English, but it doesn't actually tell me enough to figure out what's going on. Does my browser have an active session as another user? Or is my cookie invalid? Or..?
Maybe something instead like "You are currently logged in as $this_user->name but have used a password reset link for $other_user->name. Please log out and try again."
I'm on crack. Are you, too?
Comment #10
rfayThis patch addresses the issues raised in #9. It also catches the odd case of a reset link for an unknown user, which would have caused a bad error message given that we now try to load the user whose reset link we clicked.
Comment #11
rfayHere's a re-roll with a couple of tiny cosmetic changes (added a period at the end of the drupal_set_message(), changed placeholder to '%' from '@').
Comment #12
TheRec commentedThe patch is working great. I mark this RTBC looking at the previous feedbacks and because I tested this extensively.
On a side note, and out of the scope of this patch, I've discovered another bug that we should investiagte, when you try to reach a reset link that does not exist and you are not logged in, you get an access denied page (which is good) but it's repeated two times (this must be related to the way drupal_access_denied() is used). This will surely be reported in another issue but I need to further test it (with other call to drupal_access_denied()).
Comment #13
TheRec commentedComment #14
webchickCommitted to HEAD. Thanks!
Comment #16
rfayIMO, this should be ported to D6 as the same problem exists there. I know there is the issue of string-freeze, but this is a good candidate for an exception.
Comment #17
albert volkman commentedD6 backport.
Comment #18
albert volkman commented