diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java index af07c8a006..a96b088bfb 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java @@ -111,6 +111,10 @@ public class UsersController extends BaseController { @RequestParam(value = "email") String email, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "state", required = false) int state) throws Exception { + Result verifyRet = usersService.verifyUserName(userName); + if (verifyRet.getCode() != Status.SUCCESS.getCode()) { + return verifyRet; + } Map result = usersService.createUser(loginUser, userName, userPassword, email, tenantId, phone, queue, state); return returnDataList(result); @@ -570,6 +574,10 @@ public class UsersController extends BaseController { userPassword = ParameterUtils.handleEscapes(userPassword); repeatPassword = ParameterUtils.handleEscapes(repeatPassword); email = ParameterUtils.handleEscapes(email); + Result verifyRet = usersService.verifyUserName(userName); + if (verifyRet.getCode() != Status.SUCCESS.getCode()) { + return verifyRet; + } Map result = usersService.registerUser(userName, userPassword, repeatPassword, email); return returnDataList(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java index 05c715a805..5f5171c7e6 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java @@ -1336,7 +1336,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "two passwords are not same"); return result; } - User user = createUser(userName, userPassword, email, 1, "", "", Flag.NO.ordinal()); + User user = createUser(userName, userPassword, email, -1, "", "", Flag.NO.ordinal()); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, user); return result;