cherry-pick [Bug-15215][Api] non-admin should not modify tenantId and queue
#15254
This commit is contained in:
parent
f7a9d6b27b
commit
dade149f08
|
|
@ -395,6 +395,17 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
putMsg(result, Status.USER_NOT_EXIST, userId);
|
||||
return result;
|
||||
}
|
||||
|
||||
// non-admin should not modify tenantId and queue
|
||||
if (!isAdmin(loginUser)) {
|
||||
if (tenantId != null && user.getTenantId() != tenantId) {
|
||||
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(queue) && !StringUtils.equals(queue, user.getQueue())) {
|
||||
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(userName)) {
|
||||
|
||||
if (!CheckUtils.checkUserName(userName)) {
|
||||
|
|
|
|||
|
|
@ -814,6 +814,23 @@ public class UsersServiceTest {
|
|||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* get non-admin user
|
||||
*
|
||||
* @return user
|
||||
*/
|
||||
private User getNonAdminUser() {
|
||||
|
||||
User user = new User();
|
||||
user.setId(2);
|
||||
user.setUserType(UserType.GENERAL_USER);
|
||||
user.setUserName("userTest0001");
|
||||
user.setUserPassword("userTest0001");
|
||||
user.setTenantId(2);
|
||||
user.setQueue("queue");
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* get tenant
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue