Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -84,11 +84,10 @@ public ApiCommandResourceType getApiResourceType() {
public void execute() {
CallContext.current().setEventDetails("UserId: " + getId());
boolean result = _regionService.deleteUser(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
if (!result) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user");
}
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
}
}
13 changes: 10 additions & 3 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2064,13 +2064,20 @@ public AccountVO updateAccount(UpdateAccountCmd cmd) {
@Override
@ActionEvent(eventType = EventTypes.EVENT_USER_DELETE, eventDescription = "deleting User")
public boolean deleteUser(DeleteUserCmd deleteUserCmd) {
UserVO user = getValidUserVO(deleteUserCmd.getId());

final Long id = deleteUserCmd.getId();
User caller = CallContext.current().getCallingUser();
UserVO user = getValidUserVO(id);
Account account = _accountDao.findById(user.getAccountId());

if (caller.getId() == id) {
Domain domain = _domainDao.findById(account.getDomainId());
throw new InvalidParameterValueException(String.format("The caller is requesting to delete itself. As a security measure, ACS will not allow this operation." +
" To delete user %s (ID: %s, Domain: %s), request to another user with permission to execute the operation.", user.getUsername(), user.getUuid(), domain.getUuid()));
}

// don't allow to delete the user from the account of type Project
checkAccountAndAccess(user, account);
return _userDao.remove(deleteUserCmd.getId());
return _userDao.remove(id);
}

@Override
Expand Down