Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

getProjectManager().getProjectObjects is listing all project area although user does not have access

Subhajit Bhuiya August 3, 2018

ComponentAccessor.getProjectManager().getProjectObjects() is listing all project area although logged in user is member of only 1 project area. How to get list of project area for a logged in user based on his membership in project area.

2 answers

1 accepted

2 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2018

Hello @Subhajit Bhuiya

You can do it with PermissionManager

Here is example that retrieves projects where user have Browse project permission

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.permission.ProjectPermissions

def permissionManager = ComponentAccessor.getPermissionManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projects = permissionManager.getProjects(ProjectPermissions.BROWSE_PROJECTS, user)
neetubhatt February 8, 2023

@Mark Markov Is there a way to use the same in confluence to get jira project for logged in user.

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2018

Hello,

The problem is that ComponentAccessor.getProjectManager().getProjectObjects()  does not check user permissions. You should first get all projects to which a user has permissions. For example, in the code of @Mark Markov you get all projects, for which the user has Browse issues permission.

Then you can already do required actions on the returned projects.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events