Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
fix(api): return as soon as one of the conditions is fulfilled
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-dubus committed Oct 20, 2020
1 parent e8424b4 commit 0ef7d2d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ private boolean hasRelevantManagementRole(UserEntity user) {
if (user.getRoles() == null) {
return false ;
}
boolean hasOrganizationCreateUpdateDeleteRole = false;
boolean hasEnvironmentCreateUpdateDeleteRoleExceptApplication = false ;

for (UserRoleEntity userRoleEntity : user.getRoles()) {
if (userRoleEntity.getPermissions() != null) {
Expand All @@ -125,19 +123,19 @@ private boolean hasRelevantManagementRole(UserEntity user) {

if (currentScope.equals(RoleScope.ORGANIZATION)
&& isCreateUpdateOrDelete) {
hasOrganizationCreateUpdateDeleteRole = true;
return true ;
}

if (currentScope.equals(RoleScope.ENVIRONMENT)
&& !EnvironmentPermission.valueOf(permissionName).equals(EnvironmentPermission.APPLICATION)
&& isCreateUpdateOrDelete
) {
hasEnvironmentCreateUpdateDeleteRoleExceptApplication = true;
return true;
}
}
}
}

return hasOrganizationCreateUpdateDeleteRole || hasEnvironmentCreateUpdateDeleteRoleExceptApplication ;
return false;
}
}

0 comments on commit 0ef7d2d

Please sign in to comment.