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

355
Views
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 answers
Answer question

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 Report

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 Report
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!