2

I want to send one time login for all the users, So I am using drush uli and getting link like:

http://html/user/reset/1/1509979615/VBPx_FMfKeJUEt1moVcsSQGUMX_tFUSYEdEfRlmq7eA

So if the user 5 wants to use one time login, this will be used for only the user 1, right? Basically I want to set one time login for all the users.

How do I pass this URL in Drupal 8?

I just wanna know that how could use this in forgot password mail.

  • Just replace the http://html with your domain. – user21641 Nov 6 '17 at 15:37
  • @IvanJaros If the user 5 wants to use one time login, this will be used for only the user 1 right. I want to set one time login for all the users. – Panda Nov 6 '17 at 15:43
  • I am not sure about my understanding. How could I use the drush uli in drupal 8. Its confusing!. – Panda Nov 6 '17 at 15:44
  • Refer to the docs for uli. drushcommands.com/drush-8x/user/user-login - Other than that, I don't know of a way to trigger mass reset links and email it to everyone offhand. You cannot generate ONE link and use that for everyone because it won't work. Simply changing the id in the url isn't enough. Each user could come to the site and do the forgot password with their email address to get it. As for the domain, you need to set that in config. – Kevin Nov 6 '17 at 16:20
4

drush

To get one-time login for the specific user, use this syntax:

drush uli <user>

Where <user> is either uid (e.g. 5), user name, or email address for the user.

To get one-time login URL for multiple users or all, you need to run drush in the loop, e.g.

for uid in $(drush sqlq "SELECT uid FROM users"); do drush uli $uid; done

Run drush help uli for help with syntax.

To correct your http://html part, add -l http://example.com parameter, or set your $base_url in your settings file.

Custom code

If you're interested in sending one-time login via e-mail using Drupal, you can use user_pass_reset_url() function in your custom code.

Generates a unique URL for a user to login and reset their password.

Contrib module

Or use Login one time module (for D8, check this issue).

Login one time provides the ability to email one-time login links to users.

  • I will get a url like $base_url/user/reset/7/1510036033/N5suTv36MbBOMm6rrdZFFZL8TAy9GKgted97zBnu7iQ . I just wanna know that how could use this in forgot password mail. – Panda Nov 7 '17 at 6:29
  • @Panda You can use Login one time module for that. Check the updated answer. – kenorb Nov 7 '17 at 14:59
2

If you'd like to force all of your users to log in via one-time login links all the time, you could use the passwordless module.

If you set the $base_url in your settings.php file, then the Drush user-login command will generate the correct URL in the output. You could then write a simple script to email every user with their own unique login link.

There is no Drush command to email a password-reset link to a user, but there of course Drupal does this on the request password page. You could use the user module as a guide, and write a simple module or Drush command to mass-reset all users.

0

In Drush version > 9 it should be

drush uli --name=USERNAME

notice take a look at a digit after reset/{UID}/ is should be the id of user you've tried to reset

in you case user/reset/1/ it obviously reset the password for used one.

So if you want to do it for all user run the following command in your terminal :

for name in $(drush sqlq "SELECT name FROM users"); do drush uli --name=$name; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.