Problem/Motivation
If a user clicks on a "one time login link" that has expired, is invalid, or that cannot be processed because another user is already signed in, the errors displayed are shown as standard messages (e.g. appearing in green with a checkmark, depending on the theme), signifying success rather than failure.
Proposed resolution
If a one-time login link cannot be used (for any reason), this should be flagged as either a 'warning' or an 'error' instead.
Remaining tasks
Need somebody to push into core
User interface changes
Users will be presented with an 'error' or 'warning' message instead of a 'success' message if a one-time login link is unsuccessful.
DONE!
API changes
None.
Beta phase evaluation
| Issue category | Task because this does not impair functionality and is little more than a minor UX repair |
|---|---|
| Issue priority | Minor |
| Unfrozen changes | Unfrozen because it only changes the semantics of the messages displayed, and should not cause any compatability issues |
| Prioritized changes | The main goal of this issue is usability. |



Follow on issue: #2561685: Follow up to: One-time login link failure messages are misleading because they are not marked as errors
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | interdiff.txt | 700 bytes | opdavies |
| #40 | 2477641-40.patch | 2.95 KB | opdavies |
| #30 | already-logged-in.png | 30.4 KB | kaypro4 |
| #30 | expired.png | 46.38 KB | kaypro4 |
| #30 | invalid.png | 47.26 KB | kaypro4 |
Comments
Comment #1
dcam commentedThe message doesn't have a status in D8 either, so I'm bumping the version. It's an easy change, so this is a good Novice issue.
Comment #2
dcam commentedI'm not sure if this is a bug. It's maybe more of a task.
Comment #3
pguillard commentedI just added the 'error' message type.
Here is the patch.
Comment #4
tibbsa commentedComment #5
tibbsa commentedThis is an unrelated issue, but this strikes me as a bad idea. On a shared computer, User A does their thing and walks away. User B gets a reset link in their e-mail and follows it. Drupal does not allow User B to use their one-time login link, but instead openly discloses that User A is logged in -- and keeps User A logged in. User B now knows they are logged in as User A and they have free reign to go wreak havoc. Am I paranoid or does anyone else think this is perhaps a separate issue that needs some discussion?
Comment #6
opstao commentedMy original issue was with D7.36 and maybe I didn't make that clear. The patch appears to be for D8. I am hoping for a patch for D7 as well.
Comment #7
dcam commented@OpsTao
Please read the backport policy. Changes must be applied to the current development version, D8, before being applied to older versions.
It's a very small change and could be applied to D8 quickly once it passes review, which I'll try to do today. Then it can be backported to D7.
Comment #8
amytswan commentedI'm at the DrupalConLA sprint, as a novice contributor - checking out this issue. Update: Looks like this issue's in flux - letting it go...
Comment #9
amytswan commentedComment #10
kaypro4 commentedAt DrupalCon LA and going to look into this issue.
Comment #11
edutrul commentedComment #12
opstao commentedComment #13
technivant commentedReviewed and tested patch. All three use cases work as intended.
Comment #14
kaypro4 commentedTested the patch in comment #3 under the 3 scenarios in the issue description; link expired, invalid and already logged in. Error and warning messages are being displayed as expected.
Comment #15
edutrul commentedFrom @jpourzal: I am at the DrupalConLA sprint and just tested the patch with edutrul. It appears to be work since the message now appears in yellow, instead of green. Screenshot is attached(post_patch_message.png). (apologies to i8flan, we did not realize you had begun working on this)
edutrul: (apologies to i8flan, jpourzal couldn't submit the form because of request role issue...) So that's why I am posting this comment for him.
Comment #16
edutrul commentedComment #17
edutrul commentedComment #18
yoroy commentedAnybody have thoughts for the security worries in #5?
The overall change to make this a warning is ok. One nitpick unrelated to the original issue is that we want to avoid using the word "Please" in the interface copy.
Comment #19
lauriiiPublic security issues should be considered as critical.
Comment #20
opdaviesComment #21
kaypro4 commentedRE the issue brought up in comment #5, my impression is that it is not related to the UI improvements provided by this patch and should be created as a separate issue if it is deemed that it should be addressed.
Comment #22
tim.plunkettThis is just some helpful security improvement, not fixing an actual sechole, so it is not critical. The patch looks good though.
Comment #23
lauriiiThanks @tim.plunkett!
Comment #24
gyuhyon commentedI'm working on this issue during sprint @ la drupalcon
Comment #25
gyuhyon commentedI tested three cases as follows and the results look ok
- different logged-in user : warning message



- logged out status - expired time : error message
- logged out status - wrong key : error message
Comment #26
opdaviesCleaning up metadata.
Comment #27
lauriiiRTBC++, thanks for the screenshots @gyuhyon!
Comment #29
opdaviesI've re-rolled the patch from #3.
There were some conflicts whilst re-rolling, but they were resolved.
CONFLICT (content): Merge conflict in core/modules/user/src/Controller/UserController.phpComment #30
kaypro4 commentedTested the re-rolled patch from #29 and same results as before. All three scenarios are working as expected.
Comment #31
opdaviesIn that case, re-marking as RTBC. :)
Comment #32
xjm(Making the title a bit more specific since I didn't understand the scope of the issue at first.)
Comment #33
xjmThanks for the fix and for the screenshots; they definitely help clarify the issue. I agree this is a normal bugfix as the patch is currently written (simply marking these messages as errors or warnings as appropriate. I reviewed the patch locally with
git diff --color-wordsto confirm that the only changes are making these messages warnings and errors instead of happy green success messages. :)As a followup, we should get rid of the uses of "please". Reference: https://www.drupal.org/node/604342 (No need to block this change on that, though, since the pleases exist in HEAD).
Regarding @tibbsa's feedback in #5, I had the same unease with that, but that should be filed as a separate issue. Also see the related issue: #889772: Following a password reset link while logged in leaves users unable to change their password
This issue only changes user-facing strings, CSS, or markup, so per https://www.drupal.org/core/beta-changes, this can be completed any time during the Drupal 8 beta phase. Committed and pushed to 8.0.x.
Comment #35
dcam commentedThe addition of the warning/error parameters should be backport-able.
Comment #36
opdaviesThey are indeed.
For reference, I was able to test the expired link by adding
$conf['user_password_reset_timeout'] = '1';to settings.php.Comment #37
sivaji_ganesh_jojodae commentedPatch #36 fixes for account cancellation link but leaves off expired login link. Fixed the same in attached patch.
Comment #38
opdaviesHere's an interdiff between the patches in #36 and #37.
I don't think that I'm able to RTBC #37 as I wrote the patch in #36, and there's not enough difference between the two.
Comment #39
markpavlitski commentedThe changes look good, but what about:
(@opdavies, thanks for the testing tip!)
Comment #40
opdavies@markpavlitski, here's an updated patch and a new interdiff that includes that extra line.
We should also check if this line also exists in Drupal 8.
Comment #41
markpavlitski commentedRTBC for the patch in #40
and the attached D8 patch addresses the two additional messages fixed in #37 and #40.Moved into #2561685: Follow up to: One-time login link failure messages are misleading because they are not marked as errors
Comment #43
markpavlitski commented(#41 is a D8 patch)
Comment #44
markpavlitski commented(#41 is a D8 patch)Comment #45
markpavlitski commentedI've moved the D8 patch in to a follow-on ticket to avoid confusion: #2561685: Follow up to: One-time login link failure messages are misleading because they are not marked as errors
Comment #46
David_Rothstein commentedCommitted to 7.x - thanks!
The user login process tends to be heavily customized by particular sites, so I bet there's someone who cares about this or who is altering $_SESSION['messages']['status'] to change these or something crazy like that. So I'm putting this in CHANGELOG.txt and the release notes as a precaution.
Comment #48
David_Rothstein commentedBy the way, for this (from #5):
Most sites that allow users to log in make it obvious who the current logged-in user is as soon as they visit the site and look at the page, so I'm not sure why this extra message would be a problem?
It could make sense to have a separate issue to discuss logging user A out automatically in this situation, though (after all, user B is trying to log in). In practice I don't think this scenario commonly occurs at all, except for developers testing things with two different accounts on their machine :)