Reputation: 190
My project contains next-auth pages config for custom verifyRequest
pages, amongst others:
pages: {
error: "/auth/error-page",
signIn: "/auth/sign-in",
verifyRequest: "/auth/check-email",
},
I am working on a signup redesign that includes a "verify request page" in a SPA, therefore negating the need for a verifyRequest
altogether.
While rolling out the new redesign, I want to maintain the verifyRequest
for the old signup workflow.
However, both designs are implemented with a client-side use of next-auth's signIn
function, which attempts to redirect to the configured verifyRequest
by default.
Is there any way to disable the verifyRequest
or to intercept the redirect signIn
attempts to invoke?
So far I've used window.onbeforeunload
as a means to intercept, but I am hoping for a more elegant solution.
Upvotes: 1
Views: 158
Reputation: 2813
Per the docs: https://next-auth.js.org/getting-started/client#using-the-redirect-false-option
In some cases, you might want to deal with the sign in response on the same page and disable the default redirection. For example, if an error occurs (like wrong credentials given by the user), you might want to handle the error on the same page. For that, you can pass redirect: false in the second parameter object.
e.g.
signIn('credentials', { redirect: false, password: 'password' })
signIn('email', { redirect: false, email: '[email protected]' })
Upvotes: 2