mayur
mayur

Reputation: 131

Reset password link not working in drupal 8

I am getting "http://example.com/user/reset/32/1530596529/g72Z2YhSpS8L5rWDXYKNCNoU1TRKF4GDGtnn2ictl0A"

when I click on it, "it converts to http://example.com/user/reset/32/" and I get a message saying "This login can be used only once."

I want to send direct hash link in email.

I have not used reset link but it says .

"You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below."

any help would be great.

Upvotes: 0

Views: 2300

Answers (2)

zcht
zcht

Reputation: 326

This is a bit of an older issue, but is called often I see. I also had a similar issue, the problem is with the crawlers pre-scanning the link. This invalidates the link. We have created a module that prevents exactly that. Test, review and feedback are welcome.

https://www.drupal.org/project/shy_one_time

Upvotes: 0

Nikolay Volodin
Nikolay Volodin

Reputation: 31

You might have generated a link using something like

    $account = \Drupal::entityTypeManager()->getStorage('user')->load(32);
    $link = user_pass_reset_url($account);

And what you are telling seems like a normal bahavior because, yes, when you click a link it:

  1. Redirects you to a page saying "This login can be used only once." and having a Log In button in the bottom. enter image description here
  2. After clicking the button the user gets redirected to user/edit page encouraging them to change their password. But the user is already logged in at the moment. Password changing is not a necessity here enter image description here

Alternatively, you may want to run

    drush -vy uli --name="John.Doe" /user

This will generate you a link to log in immediately. You may specify a path where to redirect the user after logging them in. Check out the details here - https://drushcommands.com/drush-9x/user/user:login/

Upvotes: 2

Related Questions