Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda