Next.js Discord

Discord Forum

How to automatically login a user after they click a "verify email" link?

Unanswered
King Shepherd posted this in #help-forum
Open in Discord
King ShepherdOP
The way I'm considering doing this is by having the email link go to an API endpoint that puts a session cookie in their cookie jar, and then just using redirect("/dashboard"). after they have a session.

How do you implement this in next auth? The only way I know how to create a JWT / server session variable is with credentials:

signIn("credentials", {
            email,
            password,
            callbackUrl: "/dashboard",
        })


which sends the credentials to auth/[...nextauth]/route.ts
How can I sign them in and create a valid JWT just from them clicking the link?

0 Replies