Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Last active December 10, 2017 23:18
Show Gist options
  • Save hiranya911/aa5a0bdee5bc9ba1bdee11ca97dd98fa to your computer and use it in GitHub Desktop.
Save hiranya911/aa5a0bdee5bc9ba1bdee11ca97dd98fa to your computer and use it in GitHub Desktop.
public boolean grantModeratorRole(String uid) throws Exception {
FirebaseAuth auth = FirebaseAuth.getInstance();
UserRecord user = auth.getUserAsync(uid).get();
if (user.isEmailVerified()) {
Map<String, Object> claims = new HashMap<>();
claims.put("role", "moderator");
claims.put("level", 5);
auth.setCustomUserClaimsAsync(uid, claims).get();
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment