shwstppr commented on code in PR #9173:
URL: https://github.com/apache/cloudstack/pull/9173#discussion_r1627626654


##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -1287,16 +1287,33 @@ public Pair<Long, Account> 
doInTransaction(TransactionStatus status) {
         return _userAccountDao.findById(userId);
     }
 
-    private boolean isValidRoleChange(Account account, Role role) {
-        Long currentAccRoleId = account.getRoleId();
-        Role currentRole = roleService.findRole(currentAccRoleId);
-
-        if (role.getRoleType().ordinal() < currentRole.getRoleType().ordinal() 
&& ((account.getType() == Account.Type.NORMAL && 
role.getRoleType().getAccountType().ordinal() > Account.Type.NORMAL.ordinal()) 
||
-                account.getType().ordinal() > Account.Type.NORMAL.ordinal() && 
role.getRoleType().getAccountType().ordinal() < account.getType().ordinal() && 
role.getRoleType().getAccountType().ordinal() > 0)) {
-            throw new PermissionDeniedException(String.format("Unable to 
update account role to %s as you are " +
-                    "attempting to escalate the account %s to account type %s 
which has higher privileges", role.getName(), account.getAccountName(), 
role.getRoleType().getAccountType().name()));
+    /*
+     Role change should follow the below conditions:
+     - Caller should not be of Unknown role type
+     - New role's type should not be Unknown
+     - Caller should not be able to escalate or de-escalate an account's role 
which is of same or higher role type
+     - New role should not of type Admin with domain other than ROOT domain

Review Comment:
   ```suggestion
        - New role should not be of type Admin with domain other than ROOT 
domain
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to