Auto sign-in after sign-up

Hello, I have created a router with tRPC for the sign-up of an app. This function performs several processes, such as checking for an existing user, creating a new user in the database, and sending an OTP email. I would like to implement an auto sign-in feature after the sign-up. To achieve this, I am currently returning the email and password of the user from the tRPC route to the client side when they complete the sign-up process. Once on the client side, I run the signIn function from Next-Auth. Is this the correct and most secure approach to achieve this? Is it safe to return the email and password to the client in order to execute the signIn function? Thank you very much!
1 Reply
NotRoman
NotRoman16mo ago
This is pretty much the only way to do it with next-auth. I do something similar.

Did you find this page helpful?