When a person uses a one-time login link in order to reset her password and she is already logged in to that site, then she won't be able to reset her password. In Drupal 7, you need to know your current password in order to create a new password. The exception to that is by generating a one-time log-in. But the succssful use of that log-in depends on the person being logged out of the site when the link is used.

I propose a solution which gives a drupal_set_message of type "warning" with descriptive text and a logout link:

drupal_set_message(t('You are logged in as %user. You need to be <a href="!logout">logged out</a> in order to initiate a password change via an email link. After <a href="!logout">logging out</a>, go back to your email and click on the log-in link again there.', array('%user' => $user->name, '!logout' => url('user/logout'))), 'warning');

Shai

Comments

Shai’s picture

Issue summary: View changes

I added clarity on the problems with "Reset password" on the user/edit page.

Shai’s picture

Issue summary: View changes

typo, changed "rest" to "reset"

Shai’s picture

Issue summary: View changes

formatting: in a long post, I want to make my proposed solution stand out more.

Shai’s picture

Status: Needs review » Active
StatusFileSize
new1003 bytes

Here is a patch.

Shai’s picture

Status: Active » Needs review

Changing status to needs review so the bot will test it.

Shai’s picture

Issue summary: View changes

Silly me, I can't put a strong tag inside code tags.

Shai’s picture

Issue summary: View changes

Total simplification and rewrite of this issue... since it hasn't gotten any attention yet, I felt fine in doing that and hoping the shorter text will be more inviting for people to join in.

Shai’s picture

Issue summary: View changes

put the actual code I put in the patch.

Nephele’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new981 bytes

FYI, this overlaps significantly with #75924: Include fields for resetting password on the one-time password reset page, although I'm guessing it qualifies as a minimal bug fix separate from the refactoring being done there.

I agree that this message needs to be reworded because it is incorrect. I've reviewed and tested the patch and think it fixes the problem. Instead of adding a backport-to-d7 tag, I'm adding a d7 version of the patch (alternatively, the d8 patch can be applied using -p2 instead of -p1).

catch’s picture

Status: Reviewed & tested by the community » Needs review

Hmm if the link validates, can't we log them out on this screen rather than giving instructions?

Shai’s picture

@catch, +1, much better fix proposed than the patch.

Nephele’s picture

I'm just not sure that it makes sense to tackle anything more significant than improving the message in the context of this issue.

There's already an effort to revamp the whole password-reset feature (#75924: Include fields for resetting password on the one-time password reset page), so that's where I think larger-scale changes should be addressed. However, that's not going to get implemented until at least 8.x. In the meantime, fixing the message is a change that can be incorporated into both 7.x and 8.x to help current drupal users who encounter this problem.

FSheFF’s picture

The issue is that if users leave the edit tab on their account without changing their password the session key is abandoned and upon return they then see the current password challenge. That challenge can be removed in 7 via the No Current Pass module. Works quite well.

Shai’s picture

@FSheff,

I don't think dissabling the current password requirement is a good solution. This was a great improvement in Drupal. Just turning it off with a module, isn't a solution, when there are much betters ways to truly solve the problem.

I agree with Nephele that committing this patch and backporting to 7 would simply put us in a better place to do a more sophisticated solution that other people are already working on. But with this fix in place, we will at least prevent a lot of hair pulling for people who run into this bug.

Shai

andymartha’s picture

According to Nephele's comment in #6, "I'm just not sure that it makes sense to tackle anything more significant than improving the message in the context of this issue."

In a fresh installation of Drupal 8.x-dev from March 6, 2013, I was able to recreate the login loop/bug described in the issue. If you are logged in, you can't change your password. See screenshots.

After applying patch drupal-one_time_pw_message_when_logged_in-1872404-1.patch in #1 by Shai, the message changed to include links to logging out and a much clearer description. I was able to change my password from the email. See screenshots. The patch does as described for me.

dries’s picture

I don't understand. If you are logged in, why would you want to reset your password using a password reset link? Care to elaborate on the use case?

Shai’s picture

Dries and all,

Here is the most common case:

Some time ago, user x tried Chrome for the first time and loves it. Then she navigates in Chrime to a Drupal site example.com where she has an account. But she doesn't remember her password. She initiates the password reset process and she receives the one-time log-in in her email. Her default browser on her computer is Firefox and so the link launches Firefox. On example.com she still has an active session in her Firefox browser.

This scenario is not uncommon and really frustrating in D7. The user typically has no clue it is related to her change in browsers or the default browser setting.

Hope that helps.

Shai

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs backport to D7

Hm. #75924: Include fields for resetting password on the one-time password reset page doesn't look like it's had a patch since Nov 2012, so not sure it makes sense to hold up anything on that. I don't see why catch's suggestion wouldn't be backportable to D7. In fact, it's arguably more backportable, since a string change in such a user-facing area of the site can be problematic in stable releases.

webchick’s picture

Oh, FWIW I've totally hit the use case in #11 myself before numerous times and it'd be nice to fix it. :)

webchick’s picture

Issue tags: +Needs tests

Also, if we change the behaviour here, this will need automated tests.

Shai’s picture

@webchick,

I've never written a test before. What would be required in this case?

Anyone following this thread know what is required here re: testing?

Shai

thehong’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB

The last submitted patch, 8-1872404.diff, failed testing.

thehong’s picture

Status: Needs work » Needs review

#16: 8-1872404.diff queued for re-testing.

thehong’s picture

Issue summary: View changes

changed from code to php

xan.ps’s picture

Issue summary: View changes

The patch submitted looks good. RTBC.

ggevalt’s picture

This is an interesting discussion. It is one year old and applies to Drupal 8, yet there are lots of unresolved conversations about this same issue in D7 and D6 and D5 and D4. We are in D6… we have tested all sorts of solutions presented to this ( https://drupal.org/node/884458https://drupal.org/node/693516https://drupal.org/node/807804https://drupal.org/node/877550 … are a few) and it appears that it is related to Firefox, but perhaps not. In our case, anyone using a Firefox browser will not be able to reset the password or be able to log in after verifying a new account. They go to the link, they click "login" on their one-time login and they get an access denied message. This is a huge problem for our site

It appears that, at the moment, there is a problem in that Firefox does not log you out properly. Beyond that, we can't figure out the problem. But this seems to be a much larger issue related to core in lots of iterations. I've found references to this problem all the way back to D4.

We have been affected by this bug for many years in D4, D5 and D6. And now, it appears, it has appeared in D8 still unresolved.

I would love it if someone at this level really looked at what is going on. It is related to cookies and how Drupal handles them and how the browsers handle them and that seems pretty important.

thanks,

g

joachim’s picture

I could have sworn that I've seen a duplicate of this issue, and even possibly uploaded a patch (for D7) to it, but I can't find it! :(

joachim’s picture

jhedstrom’s picture

Status: Needs review » Closed (duplicate)

Marking this a duplicate of #889772: Following a password reset link while logged in leaves users unable to change their password as mentioned in #22. That issue has a test, and needs review.