feat: fix captcha none type bug (#1572)

This commit is contained in:
Yaodong Yu
2023-02-19 16:56:51 +08:00
committed by GitHub
parent 6131286cbd
commit e71e41b343

View File

@ -70,24 +70,27 @@ func (c *ApiController) SendVerificationCode() {
c.ResponseError(c.T("general:Missing parameter") + ": checkType.") c.ResponseError(c.T("general:Missing parameter") + ": checkType.")
return return
} }
if checkKey == "" {
c.ResponseError(c.T("general:Missing parameter") + ": checkKey.")
return
}
if !strings.Contains(applicationId, "/") { if !strings.Contains(applicationId, "/") {
c.ResponseError(c.T("verification:Wrong parameter") + ": applicationId.") c.ResponseError(c.T("verification:Wrong parameter") + ": applicationId.")
return return
} }
if captchaProvider := captcha.GetCaptchaProvider(checkType); captchaProvider == nil { if checkType != "none" {
c.ResponseError(c.T("general:don't support captchaProvider: ") + checkType) if checkKey == "" {
return c.ResponseError(c.T("general:Missing parameter") + ": checkKey.")
} else if isHuman, err := captchaProvider.VerifyCaptcha(checkKey, checkId); err != nil { return
c.ResponseError(err.Error()) }
return
} else if !isHuman { if captchaProvider := captcha.GetCaptchaProvider(checkType); captchaProvider == nil {
c.ResponseError(c.T("verification:Turing test failed.")) c.ResponseError(c.T("general:don't support captchaProvider: ") + checkType)
return 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) application := object.GetApplication(applicationId)