fix 修复 用户注册接口校验用户名不区分租户问题

2.X
疯狂的狮子Li 1 year ago
parent 17f052ea3a
commit 4981eb89b1

@ -57,14 +57,6 @@ public interface RemoteUserService {
*/
XcxLoginUser getUserInfoByOpenid(String openid) throws UserException;
/**
*
*
* @param remoteUserBo
* @return
*/
boolean checkUserNameUnique(RemoteUserBo remoteUserBo);
/**
*
*

@ -136,10 +136,7 @@ public class SysLoginService {
remoteUserBo.setNickName(username);
remoteUserBo.setPassword(BCrypt.hashpw(password));
remoteUserBo.setUserType(userType);
// 校验用户名是否唯一
if (!remoteUserService.checkUserNameUnique(remoteUserBo)) {
throw new UserException("user.register.save.error", username);
}
boolean regFlag = remoteUserService.registerUserInfo(remoteUserBo);
if (!regFlag) {
throw new UserException("user.register.error");

@ -143,11 +143,6 @@ public class RemoteUserServiceImpl implements RemoteUserService {
return loginUser;
}
@Override
public boolean checkUserNameUnique(RemoteUserBo remoteUserBo) {
return userService.checkUserNameUnique(MapstructUtils.convert(remoteUserBo, SysUserBo.class));
}
@Override
public Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException {
SysUserBo sysUserBo = MapstructUtils.convert(remoteUserBo, SysUserBo.class);
@ -155,7 +150,11 @@ public class RemoteUserServiceImpl implements RemoteUserService {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
throw new ServiceException("当前系统没有开启注册功能");
}
if (!userService.checkUserNameUnique(sysUserBo)) {
boolean exist = userMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(TenantHelper.isEnable(), SysUser::getTenantId, remoteUserBo.getTenantId())
.eq(SysUser::getUserName, sysUserBo.getUserName())
.ne(ObjectUtil.isNotNull(sysUserBo.getUserId()), SysUser::getUserId, sysUserBo.getUserId()));
if (exist) {
throw new UserException("user.register.save.error", username);
}
return userService.registerUser(sysUserBo, remoteUserBo.getTenantId());

Loading…
Cancel
Save