Skip to content

Commit 4425ee4

Browse files
authored
Remove unnecessary if-else branch in template permission validation (#12683)
* consolidate if-else branch
1 parent f6efda5 commit 4425ee4

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,16 +5034,13 @@ private Pair<List<TemplateJoinVO>, Integer> searchForTemplatesInternal(Long temp
50345034
ex.addProxyObject(template.getUuid(), "templateId");
50355035
throw ex;
50365036
}
5037+
50375038
if (!template.isPublicTemplate() && caller.getType() == Account.Type.DOMAIN_ADMIN) {
50385039
Account template_acc = accountMgr.getAccount(template.getAccountId());
50395040
DomainVO domain = _domainDao.findById(template_acc.getDomainId());
50405041
accountMgr.checkAccess(caller, domain);
5041-
}
5042-
5043-
// if template is not public, perform permission check here
5044-
else if (!template.isPublicTemplate() && caller.getType() != Account.Type.ADMIN) {
5045-
accountMgr.checkAccess(caller, null, false, template);
5046-
} else if (template.isPublicTemplate()) {
5042+
} else if (template.isPublicTemplate() || caller.getType() != Account.Type.ADMIN) {
5043+
// if template is not public or non-admin caller, perform permission check here
50475044
accountMgr.checkAccess(caller, null, false, template);
50485045
}
50495046

0 commit comments

Comments
 (0)