Skip to content

Commit

Permalink
Merge pull request #464 from mcneilco/bugfix/get-protocol-by-codeName…
Browse files Browse the repository at this point in the history
…-with-project-roles

Bugfix/get protocol by code name with project roles
  • Loading branch information
bffrost authored Feb 8, 2018
2 parents 0050129 + 52c5f1a commit 99aaa32
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions modules/ServerAPI/src/server/routes/ProtocolServiceRoutes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ exports.protocolByCodename = (req, resp) ->
if req.user? && config.all.server.project.roles.enable
serverUtilityFunctions.getRestrictedEntityFromACASServerInternal baseurl, req.user.username, "metadata", "protocol metadata", (statusCode, json) =>
#if prot is deleted, need to check if user has privs to view deleted protocols
if json.codeName? and json.ignored and !json.deleted
if config.all.client.entity?.viewDeletedRoles?
viewDeletedRoles = config.all.client.entity.viewDeletedRoles.split(",")
if json.codeName? and json.ignored and !json.deleted
if config.all.client.entity?.viewDeletedRoles?
viewDeletedRoles = config.all.client.entity.viewDeletedRoles.split(",")
else
viewDeletedRoles = []
grantedRoles = _.map req.user.roles, (role) ->
role.roleEntry.roleName
canViewDeleted = (config.all.client.entity?.viewDeletedRoles? && config.all.client.entity.viewDeletedRoles in grantedRoles)
if canViewDeleted
resp.statusCode = statusCode
resp.end JSON.stringify json
else
resp.statusCode = 500
resp.end JSON.stringify "Protocol does not exist"
else
viewDeletedRoles = []
grantedRoles = _.map req.user.roles, (role) ->
role.roleEntry.roleName
canViewDeleted = (config.all.client.entity?.viewDeletedRoles? && config.all.client.entity.viewDeletedRoles in grantedRoles)
if canViewDeleted
resp.statusCode = statusCode
resp.end JSON.stringify json
else
resp.statusCode = 500
resp.end JSON.stringify "Protocol does not exist"
else
resp.statusCode = statusCode
resp.end JSON.stringify json
else
serverUtilityFunctions.getFromACASServer baseurl, resp

Expand Down

0 comments on commit 99aaa32

Please sign in to comment.