forked from github/dataease
Merge pull request #872 from dataease/pr@dev@fix_sso_info_validate
fix: 修复sso用户信息缺失验证
This commit is contained in:
commit
7f8de5ce57
@ -77,6 +77,7 @@ public class AuthServer implements AuthApi {
|
||||
ldapAddRequest.setEnabled(1L);
|
||||
ldapAddRequest.setDeptId(1L);
|
||||
ldapAddRequest.setRoleIds(new ArrayList<Long>(){{add(2L);}});
|
||||
sysUserService.validateExistUser(ldapUserEntity.getUserName(), ldapUserEntity.getEmail());
|
||||
sysUserService.saveLdapUsers(ldapAddRequest);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class SSOServer {
|
||||
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
|
||||
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||
if(null == sysUserEntity){
|
||||
sysUserService.validateExistUser(ssoUserInfo.getUsername(), ssoUserInfo.getEmail());
|
||||
sysUserService.saveOIDCUser(ssoUserInfo);
|
||||
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||
}
|
||||
|
@ -299,6 +299,33 @@ public class SysUserService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void validateExistUser(String userName, String email) {
|
||||
SysUserExample example = new SysUserExample();
|
||||
if (StringUtils.isNotBlank(userName)) {
|
||||
example.createCriteria().andUsernameEqualTo(userName);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户ID【"+userName+"】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
/* if (StringUtils.isNotBlank(nickName)) {
|
||||
example.createCriteria().andNickNameEqualTo(nickName);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户姓名【"+nickName+"】已存在,请联系管理员");
|
||||
}
|
||||
} */
|
||||
|
||||
if (StringUtils.isNotBlank(email)) {
|
||||
example.createCriteria().andEmailEqualTo(email);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户邮箱【"+email+"】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<SysUser> users(List<Long> userIds) {
|
||||
return userIds.stream().map(sysUserMapper::selectByPrimaryKey).collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user