mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-11-30 10:58:05 +08:00
feat: 验证码输入判断逻辑修改 (#842)
This commit is contained in:
parent
379b171f0a
commit
09d462b829
@ -26,7 +26,7 @@ func (b *BaseApi) Login(c *gin.Context) {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if req.AuthMethod != "jwt" {
|
||||
if req.AuthMethod != "jwt" && !req.IgnoreCaptcha {
|
||||
if err := captcha.VerifyCode(req.CaptchaID, req.Captcha); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
|
@ -19,6 +19,7 @@ type MfaCredential struct {
|
||||
type Login struct {
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password"`
|
||||
IgnoreCaptcha bool `json:"ignoreCaptcha"`
|
||||
Captcha string `json:"captcha"`
|
||||
CaptchaID string `json:"captchaID"`
|
||||
AuthMethod string `json:"authMethod"`
|
||||
|
@ -11111,6 +11111,9 @@ var doc = `{
|
||||
"captchaID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ignoreCaptcha": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -11097,6 +11097,9 @@
|
||||
"captchaID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ignoreCaptcha": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -929,6 +929,8 @@ definitions:
|
||||
type: string
|
||||
captchaID:
|
||||
type: string
|
||||
ignoreCaptcha:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
password:
|
||||
|
@ -2,6 +2,7 @@ export namespace Login {
|
||||
export interface ReqLoginForm {
|
||||
name: string;
|
||||
password: string;
|
||||
ignoreCaptcha: boolean;
|
||||
captcha: string;
|
||||
captchaID: string;
|
||||
authMethod: string;
|
||||
|
@ -23,6 +23,7 @@ export const GlobalStore = defineStore({
|
||||
isFullScreen: false,
|
||||
agreeLicense: false,
|
||||
hasNewVersion: false,
|
||||
ignoreCaptcha: true,
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
|
@ -19,6 +19,7 @@ export interface GlobalState {
|
||||
isFullScreen: boolean;
|
||||
agreeLicense: boolean;
|
||||
hasNewVersion: boolean;
|
||||
ignoreCaptcha: boolean;
|
||||
}
|
||||
|
||||
export interface MenuState {
|
||||
|
@ -140,7 +140,7 @@
|
||||
{{ $t('commons.login.errorAuthInfo') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item prop="captcha" class="login-captcha">
|
||||
<el-form-item v-if="!globalStore.ignoreCaptcha" prop="captcha" class="login-captcha">
|
||||
<el-input v-model.trim="loginForm.captcha" :placeholder="$t('commons.login.captchaHelper')">
|
||||
<template #prefix>
|
||||
<svg-icon style="font-size: 7px" iconName="p-yanzhengma1"></svg-icon>
|
||||
@ -239,6 +239,7 @@ const loginFormRef = ref<FormInstance>();
|
||||
const loginForm = reactive({
|
||||
name: '',
|
||||
password: '',
|
||||
ignoreCaptcha: true,
|
||||
captcha: '',
|
||||
captchaID: '',
|
||||
authMethod: '',
|
||||
@ -286,11 +287,12 @@ const login = (formEl: FormInstance | undefined) => {
|
||||
let requestLoginForm = {
|
||||
name: loginForm.name,
|
||||
password: loginForm.password,
|
||||
ignoreCaptcha: globalStore.ignoreCaptcha,
|
||||
captcha: loginForm.captcha,
|
||||
captchaID: captcha.captchaID,
|
||||
authMethod: '',
|
||||
};
|
||||
if (requestLoginForm.captcha == '') {
|
||||
if (!globalStore.ignoreCaptcha && requestLoginForm.captcha == '') {
|
||||
errCaptcha.value = true;
|
||||
return;
|
||||
}
|
||||
@ -308,12 +310,14 @@ const login = (formEl: FormInstance | undefined) => {
|
||||
errAuthInfo.value = false;
|
||||
}
|
||||
if (res.message === 'ErrAuth') {
|
||||
globalStore.ignoreCaptcha = false;
|
||||
errCaptcha.value = false;
|
||||
errAuthInfo.value = true;
|
||||
}
|
||||
loginVerify();
|
||||
return;
|
||||
}
|
||||
globalStore.ignoreCaptcha = true;
|
||||
if (res.data.mfaStatus === 'enable') {
|
||||
mfaShow.value = true;
|
||||
errMfaInfo.value = false;
|
||||
|
Loading…
Reference in New Issue
Block a user