Browse Source

[Bug][dolphinscheduler-api]validated for duplicate username when creating or registering a user (#14577)

* [Bug][dolphinscheduler-api]validated for duplicate username when creating or registering a user

Signed-off-by: Gallardot <gallardot@apache.org>

* [Bug][dolphinscheduler-api]validated for duplicate username when creating or registering a user

Signed-off-by: Gallardot <gallardot@apache.org>

---------

Signed-off-by: Gallardot <gallardot@apache.org>
Co-authored-by: xiangzihao <460888207@qq.com>
Co-authored-by: Eric Gao <ericgao.apache@gmail.com>
3.2.1-prepare
Gallardot 1 year ago committed by GitHub
parent
commit
804b715643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
  2. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

8
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<String, Object> 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<Object> verifyRet = usersService.verifyUserName(userName);
if (verifyRet.getCode() != Status.SUCCESS.getCode()) {
return verifyRet;
}
Map<String, Object> result = usersService.registerUser(userName, userPassword, repeatPassword, email);
return returnDataList(result);
}

2
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;

Loading…
Cancel
Save