fix 修复 用户注册接口校验用户名不区分租户问题
parent
17f052ea3a
commit
4981eb89b1
|
|
@ -57,14 +57,6 @@ public interface RemoteUserService {
|
||||||
*/
|
*/
|
||||||
XcxLoginUser getUserInfoByOpenid(String openid) throws UserException;
|
XcxLoginUser getUserInfoByOpenid(String openid) throws UserException;
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验用户名称是否唯一
|
|
||||||
*
|
|
||||||
* @param remoteUserBo 用户信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
boolean checkUserNameUnique(RemoteUserBo remoteUserBo);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -136,10 +136,7 @@ public class SysLoginService {
|
||||||
remoteUserBo.setNickName(username);
|
remoteUserBo.setNickName(username);
|
||||||
remoteUserBo.setPassword(BCrypt.hashpw(password));
|
remoteUserBo.setPassword(BCrypt.hashpw(password));
|
||||||
remoteUserBo.setUserType(userType);
|
remoteUserBo.setUserType(userType);
|
||||||
// 校验用户名是否唯一
|
|
||||||
if (!remoteUserService.checkUserNameUnique(remoteUserBo)) {
|
|
||||||
throw new UserException("user.register.save.error", username);
|
|
||||||
}
|
|
||||||
boolean regFlag = remoteUserService.registerUserInfo(remoteUserBo);
|
boolean regFlag = remoteUserService.registerUserInfo(remoteUserBo);
|
||||||
if (!regFlag) {
|
if (!regFlag) {
|
||||||
throw new UserException("user.register.error");
|
throw new UserException("user.register.error");
|
||||||
|
|
|
||||||
|
|
@ -143,11 +143,6 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||||
return loginUser;
|
return loginUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkUserNameUnique(RemoteUserBo remoteUserBo) {
|
|
||||||
return userService.checkUserNameUnique(MapstructUtils.convert(remoteUserBo, SysUserBo.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException {
|
public Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException {
|
||||||
SysUserBo sysUserBo = MapstructUtils.convert(remoteUserBo, SysUserBo.class);
|
SysUserBo sysUserBo = MapstructUtils.convert(remoteUserBo, SysUserBo.class);
|
||||||
|
|
@ -155,7 +150,11 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||||
throw new ServiceException("当前系统没有开启注册功能");
|
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);
|
throw new UserException("user.register.save.error", username);
|
||||||
}
|
}
|
||||||
return userService.registerUser(sysUserBo, remoteUserBo.getTenantId());
|
return userService.registerUser(sysUserBo, remoteUserBo.getTenantId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue