Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(controller): add user name dup validation when create new user #1088

Merged
merged 4 commits into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import ai.starwhale.mlops.exception.SWAuthException.AuthType;
import ai.starwhale.mlops.exception.SWProcessException;
import ai.starwhale.mlops.exception.SWProcessException.ErrorType;
import ai.starwhale.mlops.exception.SWValidationException;
import ai.starwhale.mlops.exception.SWValidationException.ValidSubject;
import ai.starwhale.mlops.exception.api.StarWhaleApiException;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
Expand Down Expand Up @@ -170,7 +172,12 @@ public PageInfo<UserVO> listUsers(User user, PageParams pageParams) {
return PageUtil.toPageInfo(userEntities, userConvertor::convert);
}


public Long createUser(User user, String password, String salt) {
UserEntity userByName = userMapper.findUserByName(user.getName());//todo lock this row
if (null != userByName) {
throw new SWValidationException(ValidSubject.USER).tip("user already exists");
}
String encodedPwd;
if(StrUtil.isEmpty(salt)) {
salt = saltGenerator.salt();
Expand Down