DaanHoogland commented on code in PR #10311:
URL: https://github.com/apache/cloudstack/pull/10311#discussion_r1973097770
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -1577,11 +1592,18 @@ protected void
validateAndUpdateUsernameIfNeeded(UpdateUserCmd updateUserCmd, Us
if (duplicatedUser.getId() == user.getId()) {
continue;
}
- Account duplicatedUserAccountWithUserThatHasTheSameUserName =
_accountDao.findById(duplicatedUser.getAccountId());
- if
(duplicatedUserAccountWithUserThatHasTheSameUserName.getDomainId() ==
account.getDomainId()) {
- DomainVO domain =
_domainDao.findById(duplicatedUserAccountWithUserThatHasTheSameUserName.getDomainId());
- throw new
InvalidParameterValueException(String.format("Username [%s] already exists in
domain [id=%s,name=%s]", duplicatedUser.getUsername(), domain.getUuid(),
domain.getName()));
+
+ // duplicate usernames cannot exist in same domain unless
explicitly configured
+ if
(!userAllowMultipleAccounts.valueInDomain(account.getDomainId())) {
+ Account duplicatedUserAccountWithUserThatHasTheSameUserName =
_accountDao.findById(duplicatedUser.getAccountId());
+ if
(duplicatedUserAccountWithUserThatHasTheSameUserName.getDomainId() ==
account.getDomainId()) {
+ DomainVO domain =
_domainDao.findById(duplicatedUserAccountWithUserThatHasTheSameUserName.getDomainId());
+ throw new
InvalidParameterValueException(String.format("Username [%s] already exists in
domain [id=%s,name=%s]", duplicatedUser.getUsername(), domain.getUuid(),
domain.getName()));
+ }
Review Comment:
new method?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]