fix 修复 三方登录查询用户信息参数错误问题

2.X
疯狂的狮子Li 1 year ago
parent 7888b0e857
commit d2f61fc241

@ -21,6 +21,15 @@ public interface RemoteUserService {
*/ */
LoginUser getUserInfo(String username, String tenantId) throws UserException; LoginUser getUserInfo(String username, String tenantId) throws UserException;
/**
* id
*
* @param userId id
* @param tenantId id
* @return
*/
LoginUser getUserInfo(Long userId, String tenantId) throws UserException;
/** /**
* *
* *

@ -90,7 +90,7 @@ public class SocialAuthStrategy implements IAuthStrategy {
throw new ServiceException("对不起,你没有权限登录当前租户!"); throw new ServiceException("对不起,你没有权限登录当前租户!");
} }
LoginUser loginUser = remoteUserService.getUserInfo(socialVo.getUserName(), tenantId); LoginUser loginUser = remoteUserService.getUserInfo(socialVo.getUserId(), tenantId);
SaLoginModel model = new SaLoginModel(); SaLoginModel model = new SaLoginModel();
model.setDevice(client.getDeviceType()); model.setDevice(client.getDeviceType());
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置 // 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置

@ -62,6 +62,26 @@ public class RemoteUserServiceImpl implements RemoteUserService {
return buildLoginUser(userMapper.selectUserByUserName(username)); return buildLoginUser(userMapper.selectUserByUserName(username));
} }
@Override
public LoginUser getUserInfo(Long userId, String tenantId) throws UserException {
SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getUserName, SysUser::getStatus)
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
.eq(SysUser::getUserId, userId));
if (ObjectUtil.isNull(sysUser)) {
throw new UserException("user.not.exists", "");
}
if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus())) {
throw new UserException("user.blocked", sysUser.getUserName());
}
// 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
if (TenantHelper.isEnable()) {
return buildLoginUser(userMapper.selectTenantUserByUserName(sysUser.getUserName(), tenantId));
}
return buildLoginUser(userMapper.selectUserByUserName(sysUser.getUserName()));
}
@Override @Override
public LoginUser getUserInfoByPhonenumber(String phonenumber, String tenantId) throws UserException { public LoginUser getUserInfoByPhonenumber(String phonenumber, String tenantId) throws UserException {
SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>() SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()

Loading…
Cancel
Save