Search code examples
node.jsfirebase-authenticationfirebase-admin

custom claim for multi sub users at once using cloud function?


What is the best way to update the custom claim of multiple sub users at once using a cloud function ? I mean is would a forEach on an array of lets say a list of users emails (strings) do this job ?

const list = ['user1@example.com','user2@example.com','user3@example.com']


list.forEach((el)=>
getAuth()
  .getUserByEmail(el)
  .then((user) => {
      return getAuth().setCustomUserClaims(user.uid, {
        premium : true,
      });
  })
  .catch((error) => {
    console.log(error);
  });
  
  )


Solution

  • There is no API to updated multiple users at the same time. You have to process them each individually.