How can I find in my app if the logged In user is a Freshdesk admin ? I am using the below method to get the details of the loggedInUser.
console.log("loggedInUser data in ticketBackground.js is : ",data);
Which of these response parameters can help me determine if the user is admin -
So I think I’ll have to fetch roles using the /api/v2/roles api(using admin access token taken during app installation) and then find the administrator role id’s from that response(the non editable default roles) and then compare those role ids to each element of the loggedInUser’s role id array. If a match is found then that loggedInUser is an Admin. Does it sound right or is there any other way as well ? the response of /api/v2/roles is like below -
That is one way to do it, but if the role changes then you have to make the changes in the code and republish the app.
so instead you can try to add the role as an Iparam, so the admin can choose to give the ID manually for the role that has to be checked, this way the if there is a change in the role it’s just configuration rather than a code change.