Is the current Atlassian user an administrator?

How to know if the current user is an administrator in the Atlassian Connect add-on? Sometimes you have to spend more time than you expect on an easy task which could be: „Show different content in a page only for the current user who is an administrator.“ If you work on add-on for e.g. JIRA server instance, you can use „Permission Manager“, basically you can use every public API on backend side.
But how to get the information whether a user is an administrator in Atlassian Connect add-on? There is no REST API, no web service and this can become a BIG PROBLEM ...
Great advantage of using „Conditions“ is that they can be used in context parameters. So, when you have some page (which will show a message or different content for an administrator) defined in the plugin descriptor then it is simple to use the „user_is_admin“ condition.
Solid solution
If you run out of all the ideas, you will invent anything ... WARP drive, hot water ... maybe not all these things 🙂 There is no help on Atlassian Answers, no help on Stackoverflow ... but ... only documentation. Atlassian Connect offers conditions to be used in add-on descriptor. So, how about using a condition in the page url?
Great advantage of using „Conditions“ is that they can be used in context parameters. So, when you have some page (which will show a message or different content for an administrator) defined in the plugin descriptor then it is simple to use the „user_is_admin“ condition.
Example
{
...
"modules": {
"configurePage": {
"url": "configure-page?isAdmin={condition.user_is_admin}",
"name": {
"value": " Configuration"
},
"key": "configure-page"
}
},
...
}
Now we have the information in a page and we can extract isAdmin value from query parameters to display different content. That query parameter can be processed on backend or also on frontend side and it is up to you what fits your case better.
Read more
Contact us