Skip to content

Commit e39ad95

Browse files
committed
fix: remove captcha validation for disable OpenCaptcha option
Remove `CaptchaId` and `Captcha` fields from LoginVerify validation, and move captcha validation logic to the login handler. Fix captcha validation issue when `OpenCaptcha` option is disabled.
1 parent 0d90029 commit e39ad95

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

server/api/v1/system/sys_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (b *BaseApi) Login(c *gin.Context) {
4747
}
4848

4949
var oc bool = openCaptcha == 0 || openCaptcha < interfaceToInt(v)
50-
if oc && !store.Verify(l.CaptchaId, l.Captcha, true) {
50+
if oc && (l.Captcha == "" || l.CaptchaId == "" || !store.Verify(l.CaptchaId, l.Captcha, true)) {
5151
// 验证码次数+1
5252
global.BlackCache.Increment(key, 1)
5353
response.FailWithMessage("验证码错误", c)

server/utils/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var (
55
ApiVerify = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}}
66
MenuVerify = Rules{"Path": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}}
77
MenuMetaVerify = Rules{"Title": {NotEmpty()}}
8-
LoginVerify = Rules{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}}
8+
LoginVerify = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}}
99
RegisterVerify = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
1010
PageInfoVerify = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}}
1111
CustomerVerify = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}}

0 commit comments

Comments
 (0)