Search code examples
google-app-maker

How to check if an email address other than that of the logged-in user has Admin role?


I need to check if a email id (not necessarily of the logged in user) has Admin role. If yes then perform Action A otherwise Action B.

Is there a way we can check that?

Below link is of an issue (not exactly the same but similar) posted where it's said it is not possible. Not sure if there is any new development on this since then. Anyways my requirement is somewhat different.

How to get roles email address in AppMaker

Workarounds are welcome too.


Solution

  • From the server side you can get a list of email addresses of all admin users using:

    var admins = app.roles.Admins;
    var usersAdmin = app.getRoleMembers(admins);
    

    And then compare your email with the list returned.

    You can set who is an admin just for deployments so in preview mode, it will just return your email.

    Reference: https://developers.google.com/appmaker/scripting/api/server#App