|
|
|
@ -56,6 +56,7 @@ import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; |
|
|
|
import org.apache.dolphinscheduler.service.storage.StorageOperate; |
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
@ -161,10 +162,10 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
if (!isAdmin(loginUser)) { |
|
|
|
putMsg(result, Status.USER_NO_OPERATION_PERM); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// if (!isAdmin(loginUser)) {
|
|
|
|
// putMsg(result, Status.USER_NO_OPERATION_PERM);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(msg)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); |
|
|
|
@ -387,13 +388,13 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
putMsg(result, Status.FUNCTION_DISABLED); |
|
|
|
return result; |
|
|
|
} |
|
|
|
if (check(result, !canOperator(loginUser, userId), Status.USER_NO_OPERATION_PERM)) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
// if (check(result, !canOperator(loginUser, userId), Status.USER_NO_OPERATION_PERM)) {
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
User user; |
|
|
|
if(userId == -1){ |
|
|
|
if (userId == -1) { |
|
|
|
user = userMapper.selectByUserName(userName); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
user = userMapper.selectById(userId); |
|
|
|
} |
|
|
|
if (user == null) { |
|
|
|
@ -402,24 +403,24 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
} |
|
|
|
|
|
|
|
// non-admin should not modify tenantId and queue
|
|
|
|
if (!isAdmin(loginUser)) { |
|
|
|
if (tenantId != -1){ |
|
|
|
if (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 (!isAdmin(loginUser)) {
|
|
|
|
// if (tenantId != -1){
|
|
|
|
// if (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)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); |
|
|
|
return result; |
|
|
|
} |
|
|
|
if (userId != -1){ |
|
|
|
// if (!CheckUtils.checkUserName(userName)) {
|
|
|
|
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
if (userId != -1) { |
|
|
|
User tempUser = userMapper.queryByUserNameAccurately(userName); |
|
|
|
if (tempUser != null && tempUser.getId() != userId) { |
|
|
|
putMsg(result, Status.USER_NAME_EXIST); |
|
|
|
@ -430,25 +431,25 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(userPassword)) { |
|
|
|
if (!CheckUtils.checkPasswordLength(userPassword)) { |
|
|
|
putMsg(result, Status.USER_PASSWORD_LENGTH_ERROR); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// if (!CheckUtils.checkPasswordLength(userPassword)) {
|
|
|
|
// putMsg(result, Status.USER_PASSWORD_LENGTH_ERROR);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
user.setUserPassword(EncryptionUtils.getMd5(userPassword)); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(email)) { |
|
|
|
if (!CheckUtils.checkEmail(email)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// if (!CheckUtils.checkEmail(email)) {
|
|
|
|
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
user.setEmail(email); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) {
|
|
|
|
// putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (state == 0 && user.getState() != state && Objects.equals(loginUser.getId(), user.getId())) { |
|
|
|
putMsg(result, Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT); |
|
|
|
@ -492,18 +493,18 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
// only admin can operate
|
|
|
|
if (!isAdmin(loginUser)) { |
|
|
|
putMsg(result, Status.USER_NO_OPERATION_PERM, id); |
|
|
|
return result; |
|
|
|
} |
|
|
|
if (id != -1){ |
|
|
|
// if (!isAdmin(loginUser)) {
|
|
|
|
// putMsg(result, Status.USER_NO_OPERATION_PERM, id);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
if (id != -1) { |
|
|
|
User tempUser = userMapper.selectById(id); |
|
|
|
// check exist
|
|
|
|
if (tempUser == null) { |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, id); |
|
|
|
return result; |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
User tempUser = userMapper.selectByUserName(userName); |
|
|
|
// check exist
|
|
|
|
if (tempUser == null) { |
|
|
|
@ -1111,19 +1112,19 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { |
|
|
|
private String checkUserParams(String userName, String password, String email, String phone) { |
|
|
|
|
|
|
|
String msg = null; |
|
|
|
if (!CheckUtils.checkUserName(userName)) { |
|
|
|
|
|
|
|
msg = userName; |
|
|
|
} else if (!CheckUtils.checkPassword(password)) { |
|
|
|
|
|
|
|
msg = password; |
|
|
|
} else if (!CheckUtils.checkEmail(email)) { |
|
|
|
|
|
|
|
msg = email; |
|
|
|
} else if (!CheckUtils.checkPhone(phone)) { |
|
|
|
|
|
|
|
msg = phone; |
|
|
|
} |
|
|
|
// if (!CheckUtils.checkUserName(userName)) {
|
|
|
|
//
|
|
|
|
// msg = userName;
|
|
|
|
// } else if (!CheckUtils.checkPassword(password)) {
|
|
|
|
//
|
|
|
|
// msg = password;
|
|
|
|
// } else if (!CheckUtils.checkEmail(email)) {
|
|
|
|
//
|
|
|
|
// msg = email;
|
|
|
|
// } else if (!CheckUtils.checkPhone(phone)) {
|
|
|
|
//
|
|
|
|
// msg = phone;
|
|
|
|
// }
|
|
|
|
|
|
|
|
return msg; |
|
|
|
} |
|
|
|
|