Skip to content

Commit

Permalink
fix(InfoSubmission): correct the access control
Browse files Browse the repository at this point in the history
Signed-off-by: RadovanTomik <[email protected]>
  • Loading branch information
RadovanTomik committed Aug 18, 2024
1 parent 7efface commit e8ea9fd
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,19 @@ private boolean isAuthorizedToWrite(Long personId, Long resourceId) {
}

private boolean isAuthorizedToRead(InformationSubmission submission, Long personId) {
if (isOnlyForAdmin(submission)) {
return false;
boolean isRepresentative = isAuthorizedToWrite(personId, submission.getResource().getId());
if (isOnlyForAdmin(submission)
&& (NegotiatorUserDetailsService.isCurrentlyAuthenticatedUserAdmin() || isRepresentative)) {
return true;
}
return isAuthorizedToWrite(personId, submission.getResource().getId())
return isRepresentative
|| negotiationRepository.existsByIdAndCreatedBy_Id(
submission.getNegotiation().getId(), personId);
}

private static boolean isOnlyForAdmin(InformationSubmission submission) {
return Objects.nonNull(submission.getRequirement())
&& submission.getRequirement().isViewableOnlyByAdmin()
&& !NegotiatorUserDetailsService.isCurrentlyAuthenticatedUserAdmin();
private boolean isOnlyForAdmin(InformationSubmission submission) {
return (Objects.nonNull(submission.getRequirement())
&& submission.getRequirement().isViewableOnlyByAdmin());
}

private @NonNull InformationSubmission buildSubmissionEntity(
Expand Down

0 comments on commit e8ea9fd

Please sign in to comment.