Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Handle Email Verification Check with auth0/nextjs

I am using the library 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.

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 address, 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 is not authenticated"}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!