mirror of https://github.com/apache/cloudstack.git
Move checkRoleEscalation outside DB transaction in createAccount (#13044)
Co-authored-by: Aaron Chung <aaron_chung@apple.com>
This commit is contained in:
parent
3285e2fad8
commit
ca4645320e
|
|
@ -1341,20 +1341,19 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
|
||||
final String accountNameFinal = accountName;
|
||||
final Long domainIdFinal = domainId;
|
||||
final String accountUUIDFinal = accountUUID;
|
||||
final String resolvedAccountUUID = accountUUID != null ? accountUUID : UUID.randomUUID().toString();
|
||||
|
||||
// Check role escalation before the transaction — this is a read-only check
|
||||
// that iterates all API commands and doesn't need a write transaction open.
|
||||
AccountVO requestedAccount = new AccountVO(accountNameFinal, domainIdFinal, networkDomain, accountType, roleId, resolvedAccountUUID);
|
||||
checkRoleEscalation(getCurrentCallingAccount(), requestedAccount);
|
||||
|
||||
Pair<Long, Account> pair = Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public Pair<Long, Account> doInTransaction(TransactionStatus status) {
|
||||
// create account
|
||||
String accountUUID = accountUUIDFinal;
|
||||
if (accountUUID == null) {
|
||||
accountUUID = UUID.randomUUID().toString();
|
||||
}
|
||||
AccountVO account = createAccount(accountNameFinal, accountType, roleId, domainIdFinal, networkDomain, details, accountUUID);
|
||||
AccountVO account = createAccount(accountNameFinal, accountType, roleId, domainIdFinal, networkDomain, details, resolvedAccountUUID);
|
||||
long accountId = account.getId();
|
||||
|
||||
checkRoleEscalation(getCurrentCallingAccount(), account);
|
||||
|
||||
// create the first user for the account
|
||||
UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone, userUUID, source);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue