How do you handle advanced Email Registration with Next.js?

Hey there,

I am using the libry auth0/nextjs. I am trying to handle the email verification. I have access to the email_verification variable. If not verified, it will redirect to the page “please-verifiy-your-email”.

At the moment I am using handleCallback method which is provided by auth0/nextjs.

Code:

const afterCallback = (req, res, session, state) => {
  if (!session.user.email_verified) {
    res.status(200).redirect('/please-verifiy-your-email')
  }

  return session;
};

export default auth0.handleAuth({
    async login(req, res) {
      try {
        await auth0.handleLogin(req, res, {
          authorizationParams: {
            audience: 'https://dev-okz2bacx.us.auth0.com/api/v2/',
            scope: 'openid profile email read:branding'
          },
          returnTo: "/dashboard"
        });
      } catch (error) {
        res.status(error.status || 400).end(error.message);
      }
    },
    async callback(req, res) {
      try {
        await auth0.handleCallback(req, res, { afterCallback });
      } catch (error) {
        res.status(error.status || 500).end(error.message);
      }
    }
});

How can I make sure, the User is still logged in, to get his email for a resend or the possibility to change his email.

He also needs the chance to do a new sign up , because when I will call “api/auth/login” after login with the unverified email, it will redirect automatically to “please-verifiy-your-email’”. I guess the session is not killed and auth0 goes back redirecting even tho I didn’t had the chance to sign up again.

Would be really cool if I get a few inputs :slight_smile:

Edit:
It would solve the problem if I could log in the user and then it would redirect to “please-verifiy-your-email”. I would be able to get his email adress, name for further functions like resend verification. Right now I call “api/auth/me” I get:

{"error":"not_authenticated","description":"The user does not have an active session or i

Hi
Did you ever find a good solution for this? If so it would be appreciated if you could provide some pointers as I’m in a very similar situation.
Thanks
Marco

Unfortunately I have not found any support yet. That is why I changed the product. If you find a solution to this problem, please let me know. I may consider implementing auth0 for future projects.