Sending Login Link to Users by email

I have an application with a set of email for all the users who will be able to use it. I want to

  1. Generate a Login Link for each user
  2. Send it to their mail so that when they click on it, they will just be logged in.

My question is, how do I use Next-Auth to generate the login details for each user.

Magic Link is when a user will have to enter their mail first on the app and the login link is sent to them. I already have the users so how do I generate the link myself and send it to them straight away without coming to the app in the first place?

Hi @dephraiim,

Welcome to the Auth0 Community!

I understand that you like to send your users a login link via Email.

To do so, I recommend using a Passwordless Authentication with Magic Links flow.

In this situation, you will need to first configure the Classic Universal Login experience with the Lock (passwordless) template:

Then in the code, include the passwordlessMethod: link property in the Auth0Lock object. For example:

var lock = new Auth0LockPasswordless(config.clientID, config.auth0Domain, {
  passwordlessMethod: 'link',  
  //... redacted for brevity

Once you have configured these steps, you can have the Magic Links sent to newly created users by calling the Authentication API’s /dbconnections/signup endpoint.

Or if these users already exist, you can call the Authentication API’s /passwordless/start endpoint to begin the Passwordless authentication flow.

I hope this helps!

If you have any other questions, please feel free to reach out.

Thank you.

1 Like