Skip to content

Commit ceb601d

Browse files
committed
feat: add login settings management and captcha display logic
1 parent 6c2b2f6 commit ceb601d

File tree

12 files changed

+408
-108
lines changed

12 files changed

+408
-108
lines changed

ui/src/api/system-settings/auth-setting.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,31 @@ const putAuthSetting: (auth_type: string, data: any, loading?: Ref<boolean>) =>
3030
) => {
3131
return put(`${prefix}/${auth_type}/info`, data, undefined, loading)
3232
}
33+
/**
34+
* 登录设置
35+
*/
36+
const putLoginSetting: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
37+
data,
38+
loading
39+
) => {
40+
return put(`${prefix}/setting`, data, undefined, loading)
41+
}
42+
/**
43+
* 获取登录设置
44+
*/
45+
const getLoginSetting: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
46+
return get(`${prefix}/setting`, undefined, loading)
47+
}
48+
49+
const getLoginAuthSetting: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
50+
return get(`login/auth/setting`, undefined, loading)
51+
}
3352

3453
export default {
3554
getAuthSetting,
3655
postAuthSetting,
37-
putAuthSetting
56+
putAuthSetting,
57+
putLoginSetting,
58+
getLoginSetting,
59+
getLoginAuthSetting
3860
}

ui/src/api/user/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const logout: (loading?: Ref<boolean>) => Promise<Result<boolean>> = (loading) =
3838
* 获取验证码
3939
* @param loading 接口加载器
4040
*/
41-
const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
42-
return get('/user/captcha', undefined, loading)
41+
const getCaptcha: (username?: string, loading?: Ref<boolean>) => Promise<Result<any>> = (username, loading) => {
42+
return get('/user/captcha', {username}, loading)
4343
}
4444

4545
/**

ui/src/locales/lang/en-US/views/system.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ export default {
130130
type: 'Type',
131131
management: 'management',
132132
},
133+
default_login: 'Default Login Method',
134+
display_code: 'Display verification code when login fails',
135+
display_codeTip: 'When the value is -1, the verification code is not displayed',
136+
time: 'Times',
137+
setting: 'Login Setting',
133138
}

ui/src/locales/lang/zh-CN/views/system.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,9 @@ export default {
131131
type: '类型',
132132
management: '管理',
133133
},
134+
default_login: '默认登录方式',
135+
display_code: '登录失败显示验证码',
136+
display_codeTip: '值为-1时,不显示验证码',
137+
time: '次',
138+
setting: '登录设置',
134139
}

ui/src/locales/lang/zh-Hant/views/system.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ export default {
130130
type: '類型',
131131
management: '管理',
132132
},
133+
default_login: '預設登入方式',
134+
display_code: '登入失敗顯示驗證碼',
135+
display_codeTip: '值為-1時,不顯示驗證碼',
136+
time: '次',
137+
setting: '登录設置',
133138
}

ui/src/views/application-overview/xpack-component/XPackLimitDrawer.vue

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
step-strictly
2424
/>
2525
<span class="ml-4">{{
26-
$t('views.applicationOverview.appInfo.LimitDialog.timesDays')
27-
}}</span>
26+
$t('views.applicationOverview.appInfo.LimitDialog.timesDays')
27+
}}</span>
2828
</el-form-item>
2929
<!-- 身份验证 -->
3030
<el-form-item
@@ -74,7 +74,7 @@
7474
style="margin: 0 4px 0 0 !important"
7575
>
7676
<el-icon>
77-
<RefreshRight />
77+
<RefreshRight/>
7878
</el-icon>
7979
</el-button>
8080
</el-tooltip>
@@ -111,10 +111,32 @@
111111
>
112112
<el-checkbox-group v-model="form.authentication_value.login_value">
113113
<template v-for="t in auth_list" :key="t.value">
114-
<el-checkbox :label="t.label" :value="t.value" />
114+
<el-checkbox :label="t.label" :value="t.value"/>
115115
</template>
116116
</el-checkbox-group>
117117
</el-form-item>
118+
<el-form-item
119+
:label="$t('views.system.display_code')"
120+
:rules="[
121+
{
122+
required: true,
123+
message: $t('views.applicationOverview.appInfo.LimitDialog.displayCodeRequired'),
124+
trigger: 'change',
125+
},
126+
]"
127+
prop="authentication_value.max_attempts"
128+
>
129+
<el-input-number
130+
v-model="form.authentication_value.max_attempts"
131+
:min="-1"
132+
:max="10"
133+
:step="1"
134+
controls-position="right"
135+
/>
136+
<span style="margin-left: 8px; color: #909399; font-size: 12px;">
137+
{{ $t('views.system.display_codeTip') }}
138+
</span>
139+
</el-form-item>
118140
</el-card>
119141
</el-radio-group>
120142

@@ -144,18 +166,18 @@
144166
</el-drawer>
145167
</template>
146168
<script setup lang="ts">
147-
import { ref, watch, computed } from 'vue'
148-
import { useRoute, useRouter } from 'vue-router'
149-
import type { FormInstance, FormRules } from 'element-plus'
150-
import { MsgSuccess } from '@/utils/message'
151-
import { t } from '@/locales'
152-
import { copyClick } from '@/utils/clipboard'
153-
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
169+
import {ref, watch, computed} from 'vue'
170+
import {useRoute, useRouter} from 'vue-router'
171+
import type {FormInstance, FormRules} from 'element-plus'
172+
import {MsgSuccess} from '@/utils/message'
173+
import {t} from '@/locales'
174+
import {copyClick} from '@/utils/clipboard'
175+
import {loadSharedApi} from '@/utils/dynamics-api/shared-api'
154176
155177
const router = useRouter()
156178
const route = useRoute()
157179
const {
158-
params: { id },
180+
params: {id},
159181
} = route
160182
161183
const apiType = computed(() => {
@@ -174,6 +196,7 @@ const form = ref<any>({
174196
white_list: '',
175197
authentication_value: {
176198
type: 'password',
199+
max_attempts: 1,
177200
},
178201
authentication: false,
179202
})
@@ -197,6 +220,9 @@ const open = (data: any) => {
197220
form.value.authentication_value = data.authentication_value || {
198221
type: 'password',
199222
}
223+
if (!form.value.authentication_value.max_attempts) {
224+
form.value.authentication_value.max_attempts = 1
225+
}
200226
if (
201227
form.value.authentication_value.type === 'password' &&
202228
!form.value.authentication_value.password_value
@@ -205,7 +231,7 @@ const open = (data: any) => {
205231
}
206232
form.value.authentication = data.authentication
207233
dialogVisible.value = true
208-
loadSharedApi({ type: 'application', systemType: apiType.value })
234+
loadSharedApi({type: 'application', systemType: apiType.value})
209235
.getChatUserAuthType()
210236
.then((ok: any) => {
211237
auth_list.value = ok.data
@@ -223,7 +249,7 @@ const submit = async (formEl: FormInstance | undefined) => {
223249
authentication: form.value.authentication,
224250
authentication_value: form.value.authentication_value,
225251
}
226-
loadSharedApi({ type: 'application', systemType: apiType.value })
252+
loadSharedApi({type: 'application', systemType: apiType.value})
227253
.putAccessToken(id as string, obj, loading)
228254
.then(() => {
229255
emit('refresh')
@@ -256,7 +282,7 @@ function firstGeneration() {
256282
}
257283
}
258284
259-
defineExpose({ open })
285+
defineExpose({open})
260286
</script>
261287
<style lang="scss" scoped>
262288
.authentication-append-input {

ui/src/views/chat/user-login/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const rules = ref<FormRules<LoginRequest>>({
229229
],
230230
captcha: [
231231
{
232-
required: true,
232+
required: false,
233233
message: t('views.login.loginForm.captcha.requiredMessage'),
234234
trigger: 'blur',
235235
},
@@ -258,8 +258,8 @@ const loginHandle = () => {
258258
})
259259
}
260260
261-
function makeCode() {
262-
loginApi.getCaptcha().then((res: any) => {
261+
function makeCode(userrname?: string) {
262+
loginApi.getCaptcha(userrname).then((res: any) => {
263263
identifyCode.value = res.data.captcha
264264
})
265265
}

0 commit comments

Comments
 (0)