Skip to content

Commit 5165c6c

Browse files
committed
Merge branch '4.20' of https://github.com/apache/cloudstack into healthcheck-4.20
2 parents e9fe6d8 + 3c94936 commit 5165c6c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,16 +1579,20 @@ public UserAccount updateUser(UpdateUserCmd updateUserCmd) {
15791579
public void verifyCallerPrivilegeForUserOrAccountOperations(Account userAccount) {
15801580
logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", userAccount));
15811581

1582-
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null);
1583-
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1582+
if (!Account.Type.PROJECT.equals(userAccount.getType())) {
1583+
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null);
1584+
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1585+
}
15841586
}
15851587

15861588
protected void verifyCallerPrivilegeForUserOrAccountOperations(User user) {
15871589
logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", user));
15881590

15891591
Account userAccount = getAccount(user.getAccountId());
1590-
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user);
1591-
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1592+
if (!Account.Type.PROJECT.equals(userAccount.getType())) {
1593+
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user);
1594+
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1595+
}
15921596
}
15931597

15941598
protected void checkCallerRoleTypeAllowedForUserOrAccountOperations(Account userAccount, User user) {
@@ -1597,7 +1601,7 @@ protected void checkCallerRoleTypeAllowedForUserOrAccountOperations(Account user
15971601
RoleType userAccountRoleType = getRoleType(userAccount);
15981602

15991603
if (RoleType.Unknown == callerRoleType || RoleType.Unknown == userAccountRoleType) {
1600-
String errMsg = String.format("The role type of account [%s, %s] or [%s, %s] is unknown",
1604+
String errMsg = String.format("The role type of caller account [%s, %s] or target account [%s, %s] is unknown",
16011605
callingAccount.getName(), callingAccount.getUuid(), userAccount.getName(), userAccount.getUuid());
16021606
throw new PermissionDeniedException(errMsg);
16031607
}
@@ -2707,10 +2711,8 @@ public AccountVO createAccount(final String accountName, final Account.Type acco
27072711
}
27082712
}
27092713

2710-
if (!Account.Type.PROJECT.equals(accountType)) {
2711-
AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid);
2712-
verifyCallerPrivilegeForUserOrAccountOperations(newAccount);
2713-
}
2714+
AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid);
2715+
verifyCallerPrivilegeForUserOrAccountOperations(newAccount);
27142716

27152717
// Create the account
27162718
return Transaction.execute(new TransactionCallback<>() {

0 commit comments

Comments
 (0)