0

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);
  });
  
  )
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Richardson
  • 1,804
  • 10
  • 38

1 Answers1

2

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

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441