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

364
Visualizações
Pass parameters into Auth0 sign up

I am using Auth0's provided login and sign-up screen (https://auth0.com/docs/quickstart/webapp/nextjs/01-login#add-login-to-your-application) for my application. I set up a callback after signup where I create a profile in my DB with the email as the primary key.

The issue I'm running into is that on my home screen, I have a button that says "Sign up as admin" and another "Sign up as a user". How do I pass into this Auth0 sign up screen whether the user click "user" or "admin" so that in the callback I can create the profile with "user" or "admin"?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can add a state param to the /authorize request to maintain state between request and callback.

In Auth0, you if you need to discriminate between "user" or "admin", you could extract the state param specified the /authorize request from the context object (context.request to be specific) - see here for context object properties in Auth0 rules.

about 4 years ago · Juan Pablo Isaza Relatório

0

You do not determine signup as admin or user on the front end, this is done in backend. In auth0 authentication you add rules in auth) dashboard. When you sign in auth0, you can either select a rule template or you can create your own:

enter image description here

an example of script:

function (user, context, callback) {
  user.app_metadata = user.app_metadata || {};
  // You can add a Role based on what you want
  // In this case I check email
  //***** DETERMINE ADMINS HERE *******
  var addRolesToUser = function(user, cb) {
    if (user.email === "Email@email.com") {
      cb(null, ['admin']);
    } else {
      cb(null, ['guest']);
    }
  };

  addRolesToUser(user, function(err, roles) {
    if (err) {
      callback(err);
    } else {
      user.app_metadata.roles = roles;
      auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
        .then(function(){
          context.idToken[NAMESPACE] = user.app_metadata.roles;
          context.accessToken[NAMESPACE] = user.app_metadata.roles;
          callback(null, user, context);
        })
        .catch(function(err){
          callback(err);
        });
    }
  });
}
about 4 years ago · Juan Pablo Isaza Relatório
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