Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to bypass an Email Provider's verifyRequest page?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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: 'bill@fillmurray.com' })

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading