feat: fix stuck error when no captcha provider found (#808)

This commit is contained in:
Resulte Lee
2022-06-21 12:22:46 +08:00
committed by GitHub
parent 2e42511bc4
commit 2c57bece39
3 changed files with 27 additions and 26 deletions

View File

@ -54,25 +54,23 @@ func (c *ApiController) SendVerificationCode() {
return
}
provider := captcha.GetCaptchaProvider(checkType)
if provider == nil {
c.ResponseError("Invalid captcha provider.")
return
}
captchaProvider := captcha.GetCaptchaProvider(checkType)
if checkKey == "" {
c.ResponseError("Missing parameter: checkKey.")
return
}
isHuman, err := provider.VerifyCaptcha(checkKey, checkId)
if err != nil {
c.ResponseError("Failed to verify captcha: %v", err)
return
}
if !isHuman {
c.ResponseError("Turing test failed.")
return
if captchaProvider != nil {
if checkKey == "" {
c.ResponseError("Missing parameter: checkKey.")
return
}
isHuman, err := captchaProvider.VerifyCaptcha(checkKey, checkId)
if err != nil {
c.ResponseError("Failed to verify captcha: %v", err)
return
}
if !isHuman {
c.ResponseError("Turing test failed.")
return
}
}
user := c.getCurrentUser()