Skip to content

Commit 5f7bbad

Browse files
committed
PM-845 - allow admin to edit project even if not part of the project
1 parent 4e47782 commit 5f7bbad

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/config/constants.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,6 @@ export const PROJECT_ROLES = {
247247
COPILOT: 'copilot'
248248
}
249249

250-
export const ALLOWED_ACCEPT_PROJECT_ROLES = [
251-
'administrator',
252-
PROJECT_ROLES.MANAGER
253-
]
254-
255250
export const ALLOWED_DOWNLOAD_SUBMISSIONS_ROLES = [
256251
'administrator',
257252
PROJECT_ROLES.MANAGER,

src/util/tc.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
SUBMITTER_ROLE_UUID,
1111
READ_ONLY_ROLES,
1212
ALLOWED_DOWNLOAD_SUBMISSIONS_ROLES,
13-
ALLOWED_ACCEPT_PROJECT_ROLES,
1413
ALLOWED_EDIT_RESOURCE_ROLES
1514
} from '../config/constants'
1615
import _ from 'lodash'
@@ -195,13 +194,10 @@ export const checkEditResourceRoles = resourceRoles => {
195194
* Checks if token has any of the admin roles
196195
* @param token
197196
*/
198-
export const checkAdmin = (token, project) => {
197+
export const checkAdmin = (token) => {
199198
const tokenData = decodeToken(token)
200199
const roles = _.get(tokenData, 'roles')
201-
const isAdmin = roles.some(val => ADMIN_ROLES.indexOf(val.toLowerCase()) > -1)
202-
const canManageProject = !project || _.isEmpty(project) || ALLOWED_ACCEPT_PROJECT_ROLES.includes(_.get(_.find(project.members, { userId: tokenData.userId }), 'role'))
203-
204-
return isAdmin && canManageProject
200+
return roles.some(val => ADMIN_ROLES.indexOf(val.toLowerCase()) > -1)
205201
}
206202

207203
/**
@@ -224,11 +220,11 @@ export const checkCopilot = (token, project) => {
224220
export const checkAdminOrCopilot = (token, project) => {
225221
const tokenData = decodeToken(token)
226222
const roles = _.get(tokenData, 'roles')
227-
const allowedRoles = [...ADMIN_ROLES, ...COPILOT_ROLES]
228-
const isAdminOrCopilot = roles.some(val => allowedRoles.indexOf(val.toLowerCase()) > -1)
223+
const isAdmin = roles.some(val => ADMIN_ROLES.indexOf(val.toLowerCase()) > -1)
224+
const isCopilot = roles.some(val => COPILOT_ROLES.indexOf(val.toLowerCase()) > -1)
229225
const canManageProject = !project || _.isEmpty(project) || ALLOWED_EDIT_RESOURCE_ROLES.includes(_.get(_.find(project.members, { userId: tokenData.userId }), 'role'))
230226

231-
return isAdminOrCopilot && canManageProject
227+
return isAdmin || (isCopilot && canManageProject)
232228
}
233229

234230
/**

0 commit comments

Comments
 (0)