title: How do I set specific roles to redirect from specific routes with Custom Claims?
body: <p>I am using NodeJS, Express and plain vanilla javascript/html. Not React or anything else.</p>
  <p>With firebase I made it to when the user registers, they will automatically be called a customer (on the server-side). As shown: <br>
  <strong>server.js</strong></p>
  <pre><code>app.post('/register', (req,res) =&gt; {
      let {first_name, last_name, email, uid} = req.body;
  
      db.collection('users').doc(uid).set(req.body)
      .then(data =&gt; {
          res.json({
              uid: req.body.uid,
              first_name: req.body.first_name,
              last_name: req.body.last_name,
              email: req.body.email,
              seller: req.body.seller
          })
      })
  
      admin.auth()
      .setCustomUserClaims(uid, {
          type: &quot;customer&quot;,
      })
      .then(() =&gt; console.log('done'))
  })
  </code></pre>
  <p>But now, I would like to make this route to where it will redirect if the type is a customer.
  <strong>if(idToken.claim.type === 'customer') {redirect('/') }</strong></p>
  <pre><code>app.get('/seller', (req,res) =&gt; {
      res.sendFile(path.join(staticPath, &quot;seller.html&quot;));
  })
  </code></pre>
  <p>So I thought, what if I were to get the Token from the user and the type as soon as they log in, and send it back to the client. This will work. <br>
  <strong>login.js</strong></p>
  <pre><code>firebase.auth().currentUser.getIdTokenResult()
  .then((idTokenResult) =&gt; {
      fetch('/getMyClaims', {
          method: 'post',
          headers: {'Content-Type':'application/json'},
          body: JSON.stringify({uid: user.uid,
              idToken: idTokenResult.claims.type}),
      })
      .then(() =&gt; res.json)
      .catch(err =&gt; console.log(err));
  });
  </code></pre>
  <p>and now my server.js now includes:<br></p>
  <pre><code>app.post('/getMyClaims', async(req,res) =&gt; {
      let {uid,idToken} = req.body;
      admin.auth()
      .getUser(uid)
      .then((userRecord) =&gt; console.log(userRecord))
  })
  </code></pre>
  <p>and this is where I get stuck, because I am trying to find out how can I call the results of '/getMyClaims' to redirect a user, if they are a customer and are trying to access the '/seller' URL.
  I did read the documents as given <a href="https://firebase.google.com/docs/auth/admin/custom-claims" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/admin/custom-claims</a>, but it does not really show how to re-route if claim has a specific type in the backend.</p>