Unverified 提交 8c0098dd authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw 提交者: GitHub

Merge pull request #2228 from dataease/pr@dev@feat_default_login_type

feat: 默认登录方式设置
...@@ -42,7 +42,8 @@ public class ShiroServiceImpl implements ShiroService { ...@@ -42,7 +42,8 @@ public class ShiroServiceImpl implements ShiroService {
filterChainDefinitionMap.put("/index.html", ANON); filterChainDefinitionMap.put("/index.html", ANON);
filterChainDefinitionMap.put("/link.html", ANON); filterChainDefinitionMap.put("/link.html", ANON);
filterChainDefinitionMap.put("/board/**", ANON); filterChainDefinitionMap.put("/board/**", ANON);
filterChainDefinitionMap.put("/websocket/**", "anon"); filterChainDefinitionMap.put("/websocket/**", ANON);
filterChainDefinitionMap.put("/system/defaultLoginType", ANON);
// 获取主题信息 // 获取主题信息
filterChainDefinitionMap.put("/plugin/theme/themes", ANON); filterChainDefinitionMap.put("/plugin/theme/themes", ANON);
......
...@@ -110,6 +110,7 @@ public interface ParamConstants { ...@@ -110,6 +110,7 @@ public interface ParamConstants {
enum BASIC implements ParamConstants { enum BASIC implements ParamConstants {
FRONT_TIME_OUT("basic.frontTimeOut"), FRONT_TIME_OUT("basic.frontTimeOut"),
MSG_TIME_OUT("basic.msgTimeOut"), MSG_TIME_OUT("basic.msgTimeOut"),
DEFAULT_LOGIN_TYPE("basic.loginType"),
OPEN_HOME_PAGE("ui.openHomePage"); OPEN_HOME_PAGE("ui.openHomePage");
private String value; private String value;
......
...@@ -115,4 +115,9 @@ public class SystemParameterController { ...@@ -115,4 +115,9 @@ public class SystemParameterController {
} }
} }
@PostMapping(value = "/defaultLoginType")
public Integer defaultLoginType() {
return systemParameterService.defaultLoginType();
}
} }
...@@ -14,5 +14,7 @@ public class BasicInfo implements Serializable { ...@@ -14,5 +14,7 @@ public class BasicInfo implements Serializable {
private String msgTimeOut; private String msgTimeOut;
@ApiModelProperty("显示首页") @ApiModelProperty("显示首页")
private String openHomePage; private String openHomePage;
@ApiModelProperty("默认登录方式")
private Integer loginType = 0;
} }
...@@ -28,6 +28,7 @@ import io.dataease.ext.*; ...@@ -28,6 +28,7 @@ import io.dataease.ext.*;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class SystemParameterService { public class SystemParameterService {
private final static String LOGIN_TYPE_KEY = "basic.loginType";
@Resource @Resource
private SystemParameterMapper systemParameterMapper; private SystemParameterMapper systemParameterMapper;
@Resource @Resource
...@@ -53,6 +54,10 @@ public class SystemParameterService { ...@@ -53,6 +54,10 @@ public class SystemParameterService {
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.MSG_TIME_OUT.getValue())) { if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.MSG_TIME_OUT.getValue())) {
result.setMsgTimeOut(param.getParamValue()); result.setMsgTimeOut(param.getParamValue());
} }
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.DEFAULT_LOGIN_TYPE.getValue())) {
String paramValue = param.getParamValue();
result.setLoginType(StringUtils.isNotBlank(paramValue) ? Integer.parseInt(paramValue) : 0);
}
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.OPEN_HOME_PAGE.getValue())) { if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.OPEN_HOME_PAGE.getValue())) {
boolean open = StringUtils.equals("true", param.getParamValue()); boolean open = StringUtils.equals("true", param.getParamValue());
result.setOpenHomePage(open ? "true" : "false"); result.setOpenHomePage(open ? "true" : "false");
...@@ -126,6 +131,11 @@ public class SystemParameterService { ...@@ -126,6 +131,11 @@ public class SystemParameterService {
return param.getParamValue(); return param.getParamValue();
} }
public Integer defaultLoginType() {
String value = getValue(LOGIN_TYPE_KEY);
return StringUtils.isNotBlank(value) ? Integer.parseInt(value) : 0;
}
public List<SystemParameterDTO> getSystemParameterInfo(String paramConstantsType) { public List<SystemParameterDTO> getSystemParameterInfo(String paramConstantsType) {
List<SystemParameter> paramList = this.getParamList(paramConstantsType); List<SystemParameter> paramList = this.getParamList(paramConstantsType);
List<SystemParameterDTO> dtoList = new ArrayList<>(); List<SystemParameterDTO> dtoList = new ArrayList<>();
......
...@@ -92,3 +92,10 @@ export function getPublicKey() { ...@@ -92,3 +92,10 @@ export function getPublicKey() {
method: 'get' method: 'get'
}) })
} }
export function defaultLoginType() {
return request({
url: '/system/defaultLoginType',
method: 'post'
})
}
...@@ -637,6 +637,7 @@ export default { ...@@ -637,6 +637,7 @@ export default {
basic_setting: 'Basic setting', basic_setting: 'Basic setting',
front_time_out: 'Request timeOut(unit: second, Attention: Refresh browser takes effect after saving)', front_time_out: 'Request timeOut(unit: second, Attention: Refresh browser takes effect after saving)',
msg_time_out: 'Message retention time(unit: day)', msg_time_out: 'Message retention time(unit: day)',
login_type: 'Default login type',
empty_front: 'If empty then default value is 10s', empty_front: 'If empty then default value is 10s',
empty_msg: 'If empty then default value is 30 days', empty_msg: 'If empty then default value is 30 days',
front_error: 'Valid ranger [0 - 100]', front_error: 'Valid ranger [0 - 100]',
......
...@@ -639,6 +639,7 @@ export default { ...@@ -639,6 +639,7 @@ export default {
basic_setting: '基礎設置', basic_setting: '基礎設置',
front_time_out: '請求超時時間(單位:秒, 註意:保存後刷新瀏覽器生效)', front_time_out: '請求超時時間(單位:秒, 註意:保存後刷新瀏覽器生效)',
msg_time_out: '消息保留時間(單位:天)', msg_time_out: '消息保留時間(單位:天)',
login_type: '默認登錄方式',
empty_front: '為空則默認取值10秒', empty_front: '為空則默認取值10秒',
empty_msg: '為空則默認取值30天', empty_msg: '為空則默認取值30天',
front_error: '請填寫0-100正整數', front_error: '請填寫0-100正整數',
......
...@@ -640,6 +640,7 @@ export default { ...@@ -640,6 +640,7 @@ export default {
basic_setting: '基础设置', basic_setting: '基础设置',
front_time_out: '请求超时时间(单位:秒, 注意:保存后刷新浏览器生效)', front_time_out: '请求超时时间(单位:秒, 注意:保存后刷新浏览器生效)',
msg_time_out: '消息保留时间(单位:天)', msg_time_out: '消息保留时间(单位:天)',
login_type: '默认登录方式',
empty_front: '为空则默认取10秒', empty_front: '为空则默认取10秒',
empty_msg: '为空则默认取30天', empty_msg: '为空则默认取30天',
front_error: '请填写0-100正整数', front_error: '请填写0-100正整数',
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<script> <script>
import { encrypt } from '@/utils/rsaEncrypt' import { encrypt } from '@/utils/rsaEncrypt'
import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded } from '@/api/user' import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType } from '@/api/user'
import { getSysUI } from '@/utils/auth' import { getSysUI } from '@/utils/auth'
import { initTheme } from '@/utils/ThemeUtil' import { initTheme } from '@/utils/ThemeUtil'
import PluginCom from '@/views/system/plugin/PluginCom' import PluginCom from '@/views/system/plugin/PluginCom'
...@@ -116,10 +116,14 @@ export default { ...@@ -116,10 +116,14 @@ export default {
} }
}, },
beforeCreate() { beforeCreate() {
let p1 = null
let p2 = null
let p3 = null
pluginLoaded().then(res => { pluginLoaded().then(res => {
this.isPluginLoaded = res.success && res.data this.isPluginLoaded = res.success && res.data
this.isPluginLoaded && initTheme() this.isPluginLoaded && initTheme()
this.contentShow = true this.contentShow = true
p1 = Promise.resolve(1)
}).catch(() => { }).catch(() => {
this.contentShow = true this.contentShow = true
}) })
...@@ -128,12 +132,14 @@ export default { ...@@ -128,12 +132,14 @@ export default {
if (res.success && res.data) { if (res.success && res.data) {
this.loginTypes.push(1) this.loginTypes.push(1)
} }
p2 = Promise.resolve(2)
}) })
oidcStatus().then(res => { oidcStatus().then(res => {
if (res.success && res.data) { if (res.success && res.data) {
this.loginTypes.push(2) this.loginTypes.push(2)
} }
p3 = Promise.resolve(3)
}) })
getPublicKey().then(res => { getPublicKey().then(res => {
if (res.success && res.data) { if (res.success && res.data) {
...@@ -141,6 +147,16 @@ export default { ...@@ -141,6 +147,16 @@ export default {
localStorage.setItem('publicKey', res.data) localStorage.setItem('publicKey', res.data)
} }
}) })
defaultLoginType().then(res => {
Promise.all([p1, p2, p3]).then(() => {
if (res.success && res.data && this.loginTypes.includes(res.data)) {
this.loginForm.loginType = res.data
this.$nextTick(() => {
this.changeLoginType(this.loginForm.loginType)
})
}
})
})
}, },
mounted() { mounted() {
......
...@@ -31,6 +31,18 @@ ...@@ -31,6 +31,18 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="loginTypes.length > 1">
<el-col>
<el-form-item :label="$t('system_parameter_setting.login_type')" prop="loginType">
<el-radio-group v-model="formInline.loginType">
<el-radio :label="0" size="mini">{{ $t('login.default_login') }}</el-radio>
<el-radio v-if="loginTypes.includes(1)" :label="1" size="mini">LDAP</el-radio>
<el-radio v-if="loginTypes.includes(2)" :label="2" size="mini">OIDC</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col> <el-col>
<el-form-item :label="$t('display.openHomePage')"> <el-form-item :label="$t('display.openHomePage')">
...@@ -55,6 +67,7 @@ ...@@ -55,6 +67,7 @@
<script> <script>
import { basicInfo, updateInfo } from '@/api/system/basic' import { basicInfo, updateInfo } from '@/api/system/basic'
import { ldapStatus, oidcStatus } from '@/api/user'
export default { export default {
name: 'EmailSetting', name: 'EmailSetting',
...@@ -69,6 +82,7 @@ export default { ...@@ -69,6 +82,7 @@ export default {
show: true, show: true,
disabledSave: false, disabledSave: false,
loading: false, loading: false,
loginTypes: [0],
rules: { rules: {
frontTimeOut: [ frontTimeOut: [
{ {
...@@ -87,7 +101,19 @@ export default { ...@@ -87,7 +101,19 @@ export default {
} }
} }
}, },
beforeCreate() {
ldapStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(1)
}
})
oidcStatus().then(res => {
if (res.success && res.data) {
this.loginTypes.push(2)
}
})
},
created() { created() {
this.query() this.query()
}, },
...@@ -97,6 +123,10 @@ export default { ...@@ -97,6 +123,10 @@ export default {
basicInfo().then(response => { basicInfo().then(response => {
this.formInline = response.data this.formInline = response.data
if (this.formInline && !this.formInline.loginType) {
this.formInline.loginType = 0
}
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.formInline.clearValidate() this.$refs.formInline.clearValidate()
}) })
...@@ -113,6 +143,7 @@ export default { ...@@ -113,6 +143,7 @@ export default {
const param = [ const param = [
{ paramKey: 'basic.frontTimeOut', paramValue: this.formInline.frontTimeOut, type: 'text', sort: 1 }, { paramKey: 'basic.frontTimeOut', paramValue: this.formInline.frontTimeOut, type: 'text', sort: 1 },
{ paramKey: 'basic.msgTimeOut', paramValue: this.formInline.msgTimeOut, type: 'text', sort: 2 }, { paramKey: 'basic.msgTimeOut', paramValue: this.formInline.msgTimeOut, type: 'text', sort: 2 },
{ paramKey: 'basic.loginType', paramValue: this.formInline.loginType, type: 'text', sort: 3 },
{ paramKey: 'ui.openHomePage', paramValue: this.formInline.openHomePage, type: 'text', sort: 13 } { paramKey: 'ui.openHomePage', paramValue: this.formInline.openHomePage, type: 'text', sort: 13 }
] ]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论