server: Display proper names in error message (#5140)

Display the proper account and other names rather than the
uuid representation of the object
This commit is contained in:
Rakesh 2021-06-29 09:33:31 +02:00 committed by GitHub
parent 9ac3925936
commit 9fd38c4da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -105,7 +105,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
@Override
public boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException {
if (caller.getState() != Account.State.enabled) {
throw new PermissionDeniedException(caller + " is disabled.");
throw new PermissionDeniedException("Account " + caller.getAccountName() + " is disabled.");
}
if (domain == null) {
@ -116,10 +116,10 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
if (_accountService.isNormalUser(caller.getId())) {
if (caller.getDomainId() != domainId) {
throw new PermissionDeniedException(caller + " does not have permission to operate within domain id=" + domain.getUuid());
throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not have permission to operate within domain id=" + domain.getUuid());
}
} else if (!_domainDao.isChildDomain(caller.getDomainId(), domainId)) {
throw new PermissionDeniedException(caller + " does not have permission to operate within domain id=" + domain.getUuid());
throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not have permission to operate within domain id=" + domain.getUuid());
}
return true;
@ -155,7 +155,8 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
// account can launch a VM from this template
LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(template.getId(), caller.getId());
if (permission == null) {
throw new PermissionDeniedException(caller + " does not have permission to launch instances from " + template);
throw new PermissionDeniedException("Account " + caller.getAccountName() +
" does not have permission to launch instances from template " + template.getName());
}
} else {
// Domain admin and regular user can delete/modify only templates created by them