Checking project permissions

Checking project permissions

Available from versions: 2.7.63 3.3.13

Check whether a given user has permission to perform an operation on an issue. This can include workflow properties if required.

Check the permission scheme

boolean hasPermission(String permission, Issue issue, ApplicationUser user) returns true if the permission short name is valid and the user has the permission according to the project permission scheme.

Check the permission scheme and workflow properties

boolean hasWorkflowPermission(String permission, Issue issue, ApplicationUser user) returns true if the permission short name is valid and the user has the permission according to the project permission scheme and any workflow properties for the current workflow status.

Permission short names

The first parameter of the two permission methods takes the “short name” of a project permission. For example, “browse” is the short name of the BROWSE_PROJECTS permission.

Short name Project permission project ADMINISTER_PROJECTS browse BROWSE_PROJECTS viewversioncontrol VIEW_DEV_TOOLS viewworkflowreadonly VIEW_READONLY_WORKFLOW create CREATE_ISSUES edit EDIT_ISSUES transition TRANSITION_ISSUES scheduleissue SCHEDULE_ISSUES move MOVE_ISSUES assignable ASSIGNABLE_USER assign ASSIGN_ISSUES resolve RESOLVE_ISSUES close CLOSE_ISSUES modifyreporter MODIFY_REPORTER delete DELETE_ISSUES link LINK_ISSUES setsecurity SET_ISSUE_SECURITY viewvotersandwatchers VIEW_VOTERS_AND_WATCHERS managewatcherlist MANAGE_WATCHERS commenteditall EDIT_ALL_COMMENTS commenteditown EDIT_OWN_COMMENTS commentdeleteall DELETE_ALL_COMMENTS commentdeleteown DELETE_OWN_COMMENTS comment ADD_COMMENTS attachdeleteall DELETE_ALL_ATTACHMENTS attachdeleteown DELETE_OWN_ATTACHMENTS attach CREATE_ATTACHMENTS worklogeditown EDIT_OWN_WORKLOGS worklogeditall EDIT_ALL_WORKLOGS worklogdeleteown DELETE_OWN_WORKLOGS worklogdeleteall DELETE_ALL_WORKLOGS work WORK_ON_ISSUES

Example script

var user = userManager.getUserByName("admin"); if (jemhUtils.hasPermission("resolve", relatedIssue, user)) { print("checking permission scheme, user has resolve issue permission"); }
var user = userManager.getUserByName("admin"); if (jemhUtils.hasWorkflowPermission("comment", relatedIssue, user)) { print("checking permissions scheme AND workflow properties, user has comment permission"); }

Related articles