Auto login after sign up

Hello,

I have been trying to understand how can I autologin a user when the user is created from the backend. I’m redirecting a user to a new application where they can signup but, but I want to create the user in the backend and autologin so that the user is not disrupted.

Later I want to send an email where they can set their password. Any document with reference to the above use case will be helpful.

Thanks in advance!

Hi @vivekmanu4343,

Welcome to the Auth0 Community!

I understand that you would like to authenticate users automatically after creating them in the back end.

This presents a few issues with creating a user in the back end with a Username/Password and auto-login.

The first issue is that logging in to the user on your machine is a separate session when compared to when the user logs in to their machine. You can think of this happening when you log in on your phone and computer; they do not share the same SSO session.

The next issue is that after the user has set a new password it will require a re-authentication since password resets cause Auth0 sessions to expire. Therefore, the user must log in on their machine after setting their password.

With that, I recommend following our Send Email Invitations for Application Signup documentation to accomplish this.

I hope this helps!

Please let me know if you have any questions.

Thanks,
Rueben

Hi Ruben,

Thanks for this information. I was under the same impression until I looked into your auth0.js documentation. I could find some ref, which would allow us to auto-login without user interaction which creates a session.

I’m referring to this document. I’m looking for something similar which can be achieved. My idea here is when the user clicks on the sign-up button, we create an account using the available information in our system and with the support of management API. Later we want to somehow create the session in the front end so that their experience is not disrupted. We will be triggering an email to the user to set their password and they can use the application again only after setting up their password.

I’m building the app using react and am open to any solution.

Thanks,
Vivek P N

Hi @vivekmanu4343,

Thank you for your reply and clarification.

For this case, I recommend using the Universal Login with a Post Login Action to handle authentication and user sign ups.

First, when the user signs up using the Universal Login and clicks on the sign-up button after putting in their email and password, they will create their account and automatically log in. This auto-login behavior happens naturally with Universal Login. You can test the auto-login behavior using one of our Quickstarts and logging in with the Universal Login.

Then, with the Post Login Action, you can write a script to create the account in your system as well. This way, you can skip the complexity of creating their account, sending them an email to set their password, and handling the session post-password change.

I hope this helps!

Please let me know how if I can help you with anything else.

Thanks,
Rueben

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.