From e71e41b3433e1dae861cbf6530f3aefcb1393d47 Mon Sep 17 00:00:00 2001 From: Yaodong Yu <2814461814@qq.com> Date: Sun, 19 Feb 2023 16:56:51 +0800 Subject: [PATCH] feat: fix captcha none type bug (#1572) --- controllers/verification.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/controllers/verification.go b/controllers/verification.go index e42306f5..cef17f0f 100644 --- a/controllers/verification.go +++ b/controllers/verification.go @@ -70,24 +70,27 @@ func (c *ApiController) SendVerificationCode() { c.ResponseError(c.T("general:Missing parameter") + ": checkType.") return } - if checkKey == "" { - c.ResponseError(c.T("general:Missing parameter") + ": checkKey.") - return - } if !strings.Contains(applicationId, "/") { c.ResponseError(c.T("verification:Wrong parameter") + ": applicationId.") return } - if captchaProvider := captcha.GetCaptchaProvider(checkType); captchaProvider == nil { - c.ResponseError(c.T("general:don't support captchaProvider: ") + checkType) - return - } else if isHuman, err := captchaProvider.VerifyCaptcha(checkKey, checkId); err != nil { - c.ResponseError(err.Error()) - return - } else if !isHuman { - c.ResponseError(c.T("verification:Turing test failed.")) - return + if checkType != "none" { + if checkKey == "" { + c.ResponseError(c.T("general:Missing parameter") + ": checkKey.") + return + } + + if captchaProvider := captcha.GetCaptchaProvider(checkType); captchaProvider == nil { + c.ResponseError(c.T("general:don't support captchaProvider: ") + checkType) + return + } else if isHuman, err := captchaProvider.VerifyCaptcha(checkKey, checkId); err != nil { + c.ResponseError(err.Error()) + return + } else if !isHuman { + c.ResponseError(c.T("verification:Turing test failed.")) + return + } } application := object.GetApplication(applicationId)