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

Collabskip #3698

Open
wants to merge 2 commits into
base: feature/play_notifi
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -966,7 +966,7 @@ public ResponseEntity<GenericMessage> deleteWorkspace(
return new ResponseEntity<>(emptyResponse, HttpStatus.NOT_FOUND);
}
if (!(vo != null && vo.getWorkspaceOwner() != null
&& vo.getWorkspaceOwner().getId().equalsIgnoreCase(userId))) {
&& vo.getWorkspaceOwner().getId().equalsIgnoreCase(userId)||userStore.getUserInfo().hasSuperAdminAccess())) {
MessageDescription notAuthorizedMsg = new MessageDescription();
notAuthorizedMsg.setMessage(
"Not authorized to delete workspace. User does not have privileges.");
Expand Down Expand Up @@ -994,6 +994,7 @@ public ResponseEntity<GenericMessage> deleteWorkspace(
log.info("Cannot delete workspace {} as its not created yet. Bad Request", vo.getWorkspaceId());
return new ResponseEntity<>(errorMessage, HttpStatus.BAD_REQUEST);
}
if(!userStore.getUserInfo().hasSuperAdminAccess()){
if (vo != null && vo.getProjectDetails().getProjectOwner() != null
&& vo.getProjectDetails().getProjectOwner().getId().equalsIgnoreCase(userId)
&& vo.getProjectDetails().getProjectCollaborators() != null
Expand All @@ -1007,6 +1008,7 @@ public ResponseEntity<GenericMessage> deleteWorkspace(
"You have collaborators in your project. Please transfer your ownership to any one of the collaborator before deleting this project codespace");
return new ResponseEntity<>(errorMessage, HttpStatus.BAD_REQUEST);
}
}
GenericMessage responseMsg = service.deleteById(userId, id);
log.info("User {} deleted workspace {}", userId, vo.getWorkspaceId());
return new ResponseEntity<>(responseMsg, HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,22 @@ public GenericMessage deleteById(String userId, String id) {
GenericMessage responseMessage = new GenericMessage();
List<MessageDescription> errors = new ArrayList<>();
List<MessageDescription> warnings = new ArrayList<>();
CodeServerWorkspaceNsql entity = workspaceCustomRepository.findById(userId, id);
CodeServerWorkspaceNsql entity = new CodeServerWorkspaceNsql();

if(userStore.getUserInfo().hasSuperAdminAccess()){
entity = workspaceCustomRepository.findByWorkspaceId(id);
}
else{
entity = workspaceCustomRepository.findById(userId, id);
}
String cloudServiceProvider = entity.getData().getProjectDetails().getRecipeDetails().getCloudServiceProvider();
boolean isProjectOwner = false;
boolean isCodespaceDeployed = false;
String projectOwnerId = entity.getData().getProjectDetails().getProjectOwner().getId();
if (projectOwnerId.equalsIgnoreCase(userId)) {
if (projectOwnerId.equalsIgnoreCase(userId) ||userStore.getUserInfo().hasSuperAdminAccess()) {
isProjectOwner = true;
}


if (isProjectOwner) {
log.info("Delete requested by project owner {} ", userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring:
mvc.pathmatch.matching-strategy: ant_path_matcher
application:
name: dna-codeserver-service
version: 1.3.9
version: 1.3.10
profile:
active: production

Expand Down