Skip to content

Commit

Permalink
SHIBUI-1740
Browse files Browse the repository at this point in the history
minor code clarifications/cleanup
  • Loading branch information
chasegawa committed Jul 6, 2021
1 parent 10e7a3a commit 3b5a035
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GroupServiceImpl implements IGroupService {
@Override
public Group createGroup(Group group) throws GroupExistsConflictException {
Group foundGroup = find(group.getResourceId());
// If already defined, we can't create a new one, nor do we want this call update the definition
// If already defined, we don't want to create a new one, nor do we want this call update the definition
if (foundGroup != null) {
throw new GroupExistsConflictException(
String.format("Call update (PUT) to modify the group with resource id: [%s] and name: [%s]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum UserAccess {
ADMIN, // Access to everything
GROUP, // Group users also should have owner access
GROUP, // Group is the basic default
NONE //
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ public boolean isAuthorizedFor(Group objectGroup) {


public boolean isAuthorizedFor(String objectGroupResourceId) {
// Shouldn't be null, but for safety...
String groupId = objectGroupResourceId == null ? "" : objectGroupResourceId;

switch (getCurrentUserAccess()) { // no user returns NONE
case ADMIN:
return true;
case GROUP:
User currentUser = getCurrentUser();
// Shouldn't be null, but for safety...
String groupId = objectGroupResourceId == null ? "" : objectGroupResourceId;
return groupId.equals(currentUser.getGroupId());
default:
return false;
Expand Down

0 comments on commit 3b5a035

Please sign in to comment.