Merge pull request #807 from dataease/pr@dev@feat_oidc_sso

fix: 新增用户邮箱重复报错提示
This commit is contained in:
fit2cloud-chenyw 2021-09-10 17:13:25 +08:00 committed by GitHub
commit ad9f8b19f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 61 additions and 4 deletions

1
.gitignore vendored
View File

@ -40,6 +40,7 @@ yarn-error.log*
pnpm-debug.log* pnpm-debug.log*
# Editor directories and files # Editor directories and files
.lh
.idea .idea
.vscode .vscode
*.suo *.suo

View File

@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@RequestMapping("/api/ldap") @RequestMapping("/plugin/ldap")
@RestController @RestController
public class XLdapServer { public class XLdapServer {

View File

@ -0,0 +1,27 @@
package io.dataease.plugins.server;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RequestMapping("/plugin/oidc")
@RestController
public class XOidcServer {
@PostMapping("/info")
public List<SysSettingDto> getOidcInfo() {
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
return oidcXpackService.oidcSettings();
}
@PostMapping("/save")
public void save(@RequestBody List<SysSettingDto> settings) {
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
oidcXpackService.save(settings);
}
}

View File

@ -82,6 +82,7 @@ public class SysUserService {
@Transactional @Transactional
public int save(SysUserCreateRequest request) { public int save(SysUserCreateRequest request) {
checkUsername(request); checkUsername(request);
checkEmail(request);
SysUser user = BeanUtils.copyBean(new SysUser(), request); SysUser user = BeanUtils.copyBean(new SysUser(), request);
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
user.setCreateTime(now); user.setCreateTime(now);
@ -145,6 +146,7 @@ public class SysUserService {
@Transactional @Transactional
public int update(SysUserCreateRequest request) { public int update(SysUserCreateRequest request) {
checkUsername(request); checkUsername(request);
checkEmail(request);
if (StringUtils.isEmpty(request.getPassword())) { if (StringUtils.isEmpty(request.getPassword())) {
request.setPassword(null); request.setPassword(null);
} }
@ -287,4 +289,19 @@ public class SysUserService {
throw new RuntimeException(Translator.get("i18n_username_exists")); throw new RuntimeException(Translator.get("i18n_username_exists"));
} }
} }
private void checkEmail(SysUserCreateRequest request) {
SysUserExample sysUserExample = new SysUserExample();
SysUserExample.Criteria criteria = sysUserExample.createCriteria();
if (request.getUserId() != null) {
criteria.andUserIdNotEqualTo(request.getUserId());
}
criteria.andEmailEqualTo(request.getEmail());
List<SysUser> sysUsers = sysUserMapper.selectByExample(sysUserExample);
if (CollectionUtils.isNotEmpty(sysUsers)) {
throw new RuntimeException(Translator.get("i18n_email_exists"));
}
}
} }

View File

@ -243,6 +243,7 @@ i18n_union_field_exists=The same field can't in two dataset
i18n_cron_time_error=Start time can't greater then end time i18n_cron_time_error=Start time can't greater then end time
i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled,Please Connect Admin i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled,Please Connect Admin
i18n_username_exists=ID is already exists i18n_username_exists=ID is already exists
i18n_email_exists=Email is already exists
i18n_ds_name_exists=Datasource name used i18n_ds_name_exists=Datasource name used
i18n_sync_job_exists=There is already a synchronization task running, please try again later i18n_sync_job_exists=There is already a synchronization task running, please try again later
i18n_datasource_check_fail=Invalid,please check config i18n_datasource_check_fail=Invalid,please check config

View File

@ -242,6 +242,7 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字
i18n_cron_time_error=开始时间不能大于结束时间 i18n_cron_time_error=开始时间不能大于结束时间
i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员 i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员
i18n_username_exists=用户 ID 已存在 i18n_username_exists=用户 ID 已存在
i18n_email_exists=邮箱已存在
i18n_ds_name_exists=数据源名称已被使用 i18n_ds_name_exists=数据源名称已被使用
i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_datasource_check_fail=校验失败,请检查配置信息

View File

@ -245,6 +245,7 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字
i18n_cron_time_error=開始時間不能大於結束時間 i18n_cron_time_error=開始時間不能大於結束時間
i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员 i18n_auth_source_be_canceled=本用户当前资源所有授权权限已经被取消,如需再次开通,请联系管理员
i18n_username_exists=用戶ID已存在 i18n_username_exists=用戶ID已存在
i18n_email_exists=郵箱已存在
i18n_ds_name_exists=數據源名稱已被使用 i18n_ds_name_exists=數據源名稱已被使用
i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_datasource_check_fail=校驗失敗,請檢查配置信息

View File

@ -100,7 +100,7 @@ export function roleGrid(pageIndex, pageSize, data) {
export function ldapUsers(data) { export function ldapUsers(data) {
return request({ return request({
url: '/api/ldap/users', url: '/plugin/ldap/users',
method: 'post', method: 'post',
loading: true loading: true
}) })

View File

@ -232,7 +232,7 @@ export default {
right: 178px; right: 178px;
top: 8px; top: 8px;
background: red; background: red;
// color: #fff; color: #fff;
border-radius: 17px; border-radius: 17px;
padding: 4px 7px; padding: 4px 7px;
font-size: 16px; font-size: 16px;

View File

@ -532,6 +532,15 @@ export default {
mapping_cannot_be_empty: 'LDAP 用户属性映射不能为空', mapping_cannot_be_empty: 'LDAP 用户属性映射不能为空',
password_cannot_be_empty: 'LDAP 密码不能为空' password_cannot_be_empty: 'LDAP 密码不能为空'
}, },
oidc: {
auth_endpoint: '请输入AuthEndpoint',
token_endpoint: '请输入TokenEndpoint',
userinfo_endpoint: '请输入UserinfoEndpoint',
logout_endpoint: '请输入logoutEndpoint',
clientId: '请输入ClientId',
secret: '请输入Secret',
open: '启用OIDC认证'
},
role: { role: {
menu_authorization: '菜单授权', menu_authorization: '菜单授权',
data_authorization: '数据授权', data_authorization: '数据授权',

View File

@ -108,7 +108,7 @@ export default {
loginImageUrl: null, loginImageUrl: null,
loginLogoUrl: null, loginLogoUrl: null,
axiosFinished: false, axiosFinished: false,
openLdap: true openLdap: false
} }
}, },
computed: { computed: {