mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix for CloudStack-648
Signed-off-by: Gavin Lee <gavin.lxh@gmail.com>
This commit is contained in:
parent
5b751b2a13
commit
5aefd77f77
@ -69,6 +69,8 @@ public class UserResponse extends BaseResponse {
|
|||||||
@SerializedName("accountid") @Param(description="the account ID of the user")
|
@SerializedName("accountid") @Param(description="the account ID of the user")
|
||||||
private IdentityProxy accountId = new IdentityProxy("account");
|
private IdentityProxy accountId = new IdentityProxy("account");
|
||||||
|
|
||||||
|
@SerializedName("iscallerchilddomain") @Param(description="the boolean value representing if the updating target is in caller's child domain")
|
||||||
|
private boolean isCallerChildDomain;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id.getValue();
|
return id.getValue();
|
||||||
@ -188,4 +190,12 @@ public class UserResponse extends BaseResponse {
|
|||||||
public void setAccountId(Long accountId) {
|
public void setAccountId(Long accountId) {
|
||||||
this.accountId.setValue(accountId);
|
this.accountId.setValue(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsCallerSubdomain() {
|
||||||
|
return this.isCallerChildDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsCallerChildDomain(boolean isCallerChildDomain) {
|
||||||
|
this.isCallerChildDomain = isCallerChildDomain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ markDefaultZoneForAccount=com.cloud.api.commands.MarkDefaultZoneForAccountCmd;1
|
|||||||
#### User commands
|
#### User commands
|
||||||
createUser=com.cloud.api.commands.CreateUserCmd;3
|
createUser=com.cloud.api.commands.CreateUserCmd;3
|
||||||
deleteUser=com.cloud.api.commands.DeleteUserCmd;3
|
deleteUser=com.cloud.api.commands.DeleteUserCmd;3
|
||||||
updateUser=com.cloud.api.commands.UpdateUserCmd;3
|
updateUser=com.cloud.api.commands.UpdateUserCmd;15
|
||||||
listUsers=com.cloud.api.commands.ListUsersCmd;7
|
listUsers=com.cloud.api.commands.ListUsersCmd;7
|
||||||
####lockUser=com.cloud.api.commands.LockUserCmd;7
|
####lockUser=com.cloud.api.commands.LockUserCmd;7
|
||||||
disableUser=com.cloud.api.commands.DisableUserCmd;7
|
disableUser=com.cloud.api.commands.DisableUserCmd;7
|
||||||
|
|||||||
@ -470,6 +470,10 @@ public class ApiDBUtils {
|
|||||||
return _domainDao.findByIdIncludingRemoved(domainId);
|
return _domainDao.findByIdIncludingRemoved(domainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isChildDomain(long parentId, long childId) {
|
||||||
|
return _domainDao.isChildDomain(parentId, childId);
|
||||||
|
}
|
||||||
|
|
||||||
public static DomainRouterVO findDomainRouterById(Long routerId) {
|
public static DomainRouterVO findDomainRouterById(Long routerId) {
|
||||||
return _domainRouterDao.findByIdIncludingRemoved(routerId);
|
return _domainRouterDao.findByIdIncludingRemoved(routerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -423,6 +423,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserResponse createUserResponse(UserAccount user) {
|
public UserResponse createUserResponse(UserAccount user) {
|
||||||
|
Account account = UserContext.current().getCaller();
|
||||||
UserResponse userResponse = new UserResponse();
|
UserResponse userResponse = new UserResponse();
|
||||||
userResponse.setAccountName(user.getAccountName());
|
userResponse.setAccountName(user.getAccountName());
|
||||||
userResponse.setAccountType(user.getType());
|
userResponse.setAccountType(user.getType());
|
||||||
@ -439,8 +440,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
userResponse.setApiKey(user.getApiKey());
|
userResponse.setApiKey(user.getApiKey());
|
||||||
userResponse.setSecretKey(user.getSecretKey());
|
userResponse.setSecretKey(user.getSecretKey());
|
||||||
userResponse.setAccountId((user.getAccountId()));
|
userResponse.setAccountId((user.getAccountId()));
|
||||||
|
userResponse.setIsCallerChildDomain(ApiDBUtils.isChildDomain(account.getDomainId(), user.getDomainId()));
|
||||||
userResponse.setObjectName("user");
|
userResponse.setObjectName("user");
|
||||||
|
|
||||||
return userResponse;
|
return userResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1253,15 +1253,13 @@
|
|||||||
if(jsonObj.state == "enabled") {
|
if(jsonObj.state == "enabled") {
|
||||||
allowedActions.push("disable");
|
allowedActions.push("disable");
|
||||||
allowedActions.push("lock");
|
allowedActions.push("lock");
|
||||||
}
|
} else if(jsonObj.state == "disabled" || jsonObj.state == "locked") {
|
||||||
else if(jsonObj.state == "disabled" || jsonObj.state == "locked") {
|
|
||||||
allowedActions.push("enable");
|
allowedActions.push("enable");
|
||||||
}
|
}
|
||||||
allowedActions.push("remove");
|
allowedActions.push("remove");
|
||||||
}
|
}
|
||||||
allowedActions.push("updateResourceCount");
|
allowedActions.push("updateResourceCount");
|
||||||
}
|
} else if(isDomainAdmin()) {
|
||||||
else if(isDomainAdmin()) {
|
|
||||||
allowedActions.push("updateResourceCount");
|
allowedActions.push("updateResourceCount");
|
||||||
}
|
}
|
||||||
return allowedActions;
|
return allowedActions;
|
||||||
@ -1281,6 +1279,10 @@
|
|||||||
allowedActions.push("enable");
|
allowedActions.push("enable");
|
||||||
allowedActions.push("remove");
|
allowedActions.push("remove");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(isSelfOrChildDomainUser(jsonObj.username, jsonObj.accounttype, jsonObj.domainid, jsonObj.iscallerchilddomain)) {
|
||||||
|
allowedActions.push("changePassword");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return allowedActions;
|
return allowedActions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,6 +158,22 @@ function isUser() {
|
|||||||
return (g_role == 0);
|
return (g_role == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSelfOrChildDomainUser(username, useraccounttype, userdomainid, iscallerchilddomain) {
|
||||||
|
if(username == g_username) { //is self
|
||||||
|
return true;
|
||||||
|
} else if(isDomainAdmin()
|
||||||
|
&& iscallerchilddomain
|
||||||
|
&& (useraccounttype == 0)) { //domain admin to user
|
||||||
|
return true;
|
||||||
|
} else if(isDomainAdmin()
|
||||||
|
&& iscallerchilddomain
|
||||||
|
&& (userdomainid != g_domainid) ) { //domain admin to subdomain admin and user
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: Handles AJAX error callbacks. You can pass in an optional function to
|
// FUNCTION: Handles AJAX error callbacks. You can pass in an optional function to
|
||||||
// handle errors that are not already handled by this method.
|
// handle errors that are not already handled by this method.
|
||||||
function handleError(XMLHttpResponse, handleErrorCallback) {
|
function handleError(XMLHttpResponse, handleErrorCallback) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user