forked from forgejo/forgejo
Make captcha and password optional for external accounts (#6606)
This commit is contained in:
parent
337d6915ff
commit
62d6127f1b
7 changed files with 88 additions and 47 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue