Custom sign-in form for email magic link provider doesn't work #5368
Unanswered
AndrewRayCode
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to implement an ajax form for magic-link-email sign-in, where the user enters their email and they're emailed either a sign-up or log-in link based on if they have an account.
From a UX perspective, the way this should work is the user should enter their email into an input box, click a button, get a loading spinner, and without any redirects, get a message like "your magic email link is on the way." They should not be redirected to a separate sign-in page, which doesn't make sense for magic email links.
According to https://next-auth.js.org/configuration/pages#email-sign-in you can submit to
/api/auth/signin/email
:However, when I instrument this on my page, and submit the form via an ajax POST with a json body, something like
post('/api/auth/signin/email', { email })
(form encoded), it returns a redirect to http://localhost/api/auth/signin?csrf=true, which dies with ERR_CONNECTION_REFUSED
Is it possible to instrument this via ajax to avoid a separate "sign in" page via email? Was the EmailProvider overlooked compared to the other sign-in UX flows? Or (more likely) am I missing something obvious?
Also, the docs say this:
Which doesn't make sense. What does this mean? How does this relate to submitting the form? Do you call
signIn()
while intercepting the form submit?Beta Was this translation helpful? Give feedback.
All reactions