You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/03/30 09:41:12 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #6156: api: Update account type when updating account role

DaanHoogland commented on a change in pull request #6156:
URL: https://github.com/apache/cloudstack/pull/6156#discussion_r838338655



##########
File path: server/src/main/java/com/cloud/user/AccountManagerImpl.java
##########
@@ -1897,7 +1897,17 @@ public AccountVO updateAccount(UpdateAccountCmd cmd) {
                         "in the domain '" + domainId + "'.");
             }
 
+            Role role = roleService.findRole(roleId);
+            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)) {

Review comment:
       This condition is hard to read,
   Can you extract it to a method like `isRoleEscalation(...)` and indent according to the logic of it, please?
   It would make sense to extract the entire block as well, i.e. `checkForRoleEscalation(...)`.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org