diff options
author | AJ ONeal <coolaj86@gmail.com> | 2019-07-06 13:48:02 -0600 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-07-06 15:48:02 -0400 |
commit | 62d6127f1b945b3160d337a190b33aa96e0f60b5 (patch) | |
tree | e7cee9a32d2c6922eec0839515dd4f76bb6d8232 /routers/user/auth_openid.go | |
parent | 337d6915ff8967637ff515108612c3a7a4f51585 (diff) | |
download | gitea-62d6127f1b945b3160d337a190b33aa96e0f60b5.tar.gz gitea-62d6127f1b945b3160d337a190b33aa96e0f60b5.zip |
Make captcha and password optional for external accounts (#6606)
Diffstat (limited to 'routers/user/auth_openid.go')
-rw-r--r-- | routers/user/auth_openid.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/routers/user/auth_openid.go b/routers/user/auth_openid.go index f98c07acd7..d6baf0d92b 100644 --- a/routers/user/auth_openid.go +++ b/routers/user/auth_openid.go @@ -357,19 +357,23 @@ func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.Si ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey ctx.Data["OpenID"] = oid - if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ImageCaptcha && !cpt.VerifyReq(ctx.Req) { - ctx.Data["Err_Captcha"] = true - ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUpOID, &form) - return - } - - if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ReCaptcha { - err := ctx.Req.ParseForm() - if err != nil { - ctx.ServerError("", err) + if setting.Service.EnableCaptcha { + var valid bool + switch setting.Service.CaptchaType { + case setting.ImageCaptcha: + valid = cpt.VerifyReq(ctx.Req) + case setting.ReCaptcha: + err := ctx.Req.ParseForm() + if err != nil { + ctx.ServerError("", err) + return + } + valid, _ = recaptcha.Verify(form.GRecaptchaResponse) + default: + ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType)) return } - valid, _ := recaptcha.Verify(form.GRecaptchaResponse) + if !valid { ctx.Data["Err_Captcha"] = true ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUpOID, &form) |