From 09d462b829687d240ca2e03a7d766a7301cab0fa Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:58:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=AA=8C=E8=AF=81=E7=A0=81=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20(#842)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/auth.go | 2 +- backend/app/dto/auth.go | 11 ++++++----- cmd/server/docs/docs.go | 3 +++ cmd/server/docs/swagger.json | 3 +++ cmd/server/docs/swagger.yaml | 2 ++ frontend/src/api/interface/auth.ts | 1 + frontend/src/store/index.ts | 1 + frontend/src/store/interface/index.ts | 1 + frontend/src/views/login/components/login-form.vue | 8 ++++++-- 9 files changed, 24 insertions(+), 8 deletions(-) diff --git a/backend/app/api/v1/auth.go b/backend/app/api/v1/auth.go index c576b6fb6..cf532bd3a 100644 --- a/backend/app/api/v1/auth.go +++ b/backend/app/api/v1/auth.go @@ -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 diff --git a/backend/app/dto/auth.go b/backend/app/dto/auth.go index 1b385f378..50e06a4d9 100644 --- a/backend/app/dto/auth.go +++ b/backend/app/dto/auth.go @@ -17,11 +17,12 @@ type MfaCredential struct { } type Login struct { - Name string `json:"name"` - Password string `json:"password"` - Captcha string `json:"captcha"` - CaptchaID string `json:"captchaID"` - AuthMethod string `json:"authMethod"` + Name string `json:"name"` + Password string `json:"password"` + IgnoreCaptcha bool `json:"ignoreCaptcha"` + Captcha string `json:"captcha"` + CaptchaID string `json:"captchaID"` + AuthMethod string `json:"authMethod"` } type MFALogin struct { diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index f85219ea5..6ddb6664e 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -11111,6 +11111,9 @@ var doc = `{ "captchaID": { "type": "string" }, + "ignoreCaptcha": { + "type": "boolean" + }, "name": { "type": "string" }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 2a55b3ad6..eba0b8eb9 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -11097,6 +11097,9 @@ "captchaID": { "type": "string" }, + "ignoreCaptcha": { + "type": "boolean" + }, "name": { "type": "string" }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index cd1665f65..125995550 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -929,6 +929,8 @@ definitions: type: string captchaID: type: string + ignoreCaptcha: + type: boolean name: type: string password: diff --git a/frontend/src/api/interface/auth.ts b/frontend/src/api/interface/auth.ts index 4c2a88eb6..a8391fcbc 100644 --- a/frontend/src/api/interface/auth.ts +++ b/frontend/src/api/interface/auth.ts @@ -2,6 +2,7 @@ export namespace Login { export interface ReqLoginForm { name: string; password: string; + ignoreCaptcha: boolean; captcha: string; captchaID: string; authMethod: string; diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index 1ebf73f77..0099fa1e1 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -23,6 +23,7 @@ export const GlobalStore = defineStore({ isFullScreen: false, agreeLicense: false, hasNewVersion: false, + ignoreCaptcha: true, }), getters: {}, actions: { diff --git a/frontend/src/store/interface/index.ts b/frontend/src/store/interface/index.ts index 202471f27..7065646ba 100644 --- a/frontend/src/store/interface/index.ts +++ b/frontend/src/store/interface/index.ts @@ -19,6 +19,7 @@ export interface GlobalState { isFullScreen: boolean; agreeLicense: boolean; hasNewVersion: boolean; + ignoreCaptcha: boolean; } export interface MenuState { diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index 7242eb3cf..fed68c51d 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -140,7 +140,7 @@ {{ $t('commons.login.errorAuthInfo') }} - +