Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor should have access to view an activity. #1650

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,29 @@ class BioActivityController {
return result
}

private Map checkUserViewPermission (Map project, Map pActivity, Map activity) {
Map result = [ message: "Access denied: You are not allowed to edit activity", authorized: false ]
String userId = userService.getCurrentUserId()
String projectId = project?.projectId
Boolean embargoed = (activity.embargoed == true) || projectActivityService.isEmbargoed(pActivity)

if (!userId) {
result.message = "Only members associated to this project can submit record. For more information, please contact ${grailsApplication.config.biocollect.support.email.address}"
} else if (!activity || activity.error) {
result.message = "Invalid activity - ${id}"
} else if (embargoed) {
result.message = "Access denied: This activity is embargoed."
} else if (projectService.isUserEditorForProjects(userId, projectId) || activityService.isUserOwnerForActivity(userId, activity?.activityId)) {
result.message = "User is authorized to edit activity"
result.authorized = true
}

return result
}

private Map checkUserPermission (Map project, Map pActivity, Map activity) {
if (activity) {
return checkUserEditPermission(project, activity)
return checkUserViewPermission(project, pActivity, activity)
} else {
return checkUserCreatePermission(project, pActivity)
}
Expand Down
Loading