Skip to content

Commit

Permalink
feat: use new centralized space API with ACL management - MEED-7488 - M…
Browse files Browse the repository at this point in the history
…eeds-io/MIPs#147

This change will reuse the centralized way to check user priviledges on spaces contents.
  • Loading branch information
boubaker authored and exo-swf committed Sep 26, 2024
1 parent ede23fc commit 0b70482
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,7 @@ public static boolean isUserSpaceMember(String spaceId, String accesssor) {
throw new IllegalStateException("Space not found with id '" + spaceId + "'");
}
SpaceService spaceService = CommonsUtils.getService(SpaceService.class);
return spaceService.isSuperManager(accesssor) || spaceService.isMember(space, accesssor)
|| spaceService.isManager(space, accesssor);
return spaceService.canViewSpace(space, accesssor);
}

public static boolean checkUserIsSpaceManager(String spaceId,
Expand All @@ -693,7 +692,7 @@ public static boolean checkUserIsSpaceManager(String spaceId,
throw new IllegalStateException("Space not found with id '" + spaceId + "'");
}
SpaceService spaceService = CommonsUtils.getService(SpaceService.class);
if (!spaceService.isManager(space, modifier) && !spaceService.isSuperManager(modifier)) {
if (!spaceService.canManageSpace(space, modifier)) {
if (throwException) {
LOG.error("User '{}' attempts to access wallet address of space '{}'", modifier, space.getDisplayName());
throw new IllegalAccessException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public Space updateSpace(Space existingSpace) {
throw new UnsupportedOperationException();
}

public Space updateSpaceAvatar(Space existingSpace) {
public Space updateSpaceAvatar(Space existingSpace, String username) {
throw new UnsupportedOperationException();
}

public Space updateSpaceBanner(Space existingSpace) {
public Space updateSpaceBanner(Space existingSpace, String username) {
throw new UnsupportedOperationException();
}

Expand Down Expand Up @@ -296,7 +296,7 @@ public void renameSpace(Space space, String newDisplayName) throws SpaceExceptio

}

public void renameSpace(String remoteId, Space space, String newDisplayName) throws SpaceException {
public void renameSpace(Space space, String newDisplayName, String remoteId) throws SpaceException {
throw new UnsupportedOperationException();

}
Expand Down Expand Up @@ -551,14 +551,6 @@ public void unregisterSpaceLifeCycleListener(SpaceLifeCycleListener listener) {

}

public void setPortletsPrefsRequired(PortletPreferenceRequiredPlugin portletPrefsRequiredPlugin) {
// Nothing to change
}

public String[] getPortletsPrefsRequired() {
throw new UnsupportedOperationException();
}

public ListAccess<Space> getVisitedSpaces(String remoteId, String appId) {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,7 @@ private boolean displayTransactionsLabel(Wallet senderWallet, String currentUser
}

if (WalletType.isSpace(senderWallet.getType())) {
if (getSpaceService().isSuperManager(currentUserId)) {
return true;
}
Space space = getSpace(accountId);
return space != null && getSpaceService().isManager(space, currentUserId);
return getSpaceService().canManageSpace(getSpace(accountId), currentUserId);
} else {
return StringUtils.equalsIgnoreCase(accountId, currentUserId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public Space updateSpace(Space existingSpace) {
return existingSpace;
}

public Space updateSpaceAvatar(Space existingSpace) {
public Space updateSpaceAvatar(Space existingSpace, String username) {
throw new UnsupportedOperationException();
}

public Space updateSpaceBanner(Space existingSpace) {
public Space updateSpaceBanner(Space existingSpace, String username) {
throw new UnsupportedOperationException();
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public void renameSpace(Space space, String newDisplayName) throws SpaceExceptio

}

public void renameSpace(String remoteId, Space space, String newDisplayName) throws SpaceException {
public void renameSpace(Space space, String newDisplayName, String remoteId) throws SpaceException {
throw new UnsupportedOperationException();

}
Expand Down Expand Up @@ -560,14 +560,6 @@ public void unregisterSpaceLifeCycleListener(SpaceLifeCycleListener listener) {

}

public void setPortletsPrefsRequired(PortletPreferenceRequiredPlugin portletPrefsRequiredPlugin) {
// Nothing to do
}

public String[] getPortletsPrefsRequired() {
return new String[0];
}

public ListAccess<Space> getVisitedSpaces(String remoteId, String appId) {
throw new UnsupportedOperationException();
}
Expand Down

0 comments on commit 0b70482

Please sign in to comment.