forked from forgejo/forgejo
Add support mCaptcha as captcha provider (#20458)
https://mcaptcha.org/ Co-authored-by: Felipe Leopoldo Sologuren Gutiérrez <fsologureng@users.noreply.github.com>
This commit is contained in:
parent
452272c038
commit
58de07e5fd
20 changed files with 183 additions and 6 deletions
|
@ -18,6 +18,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/eventsource"
|
||||
"code.gitea.io/gitea/modules/hcaptcha"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/mcaptcha"
|
||||
"code.gitea.io/gitea/modules/password"
|
||||
"code.gitea.io/gitea/modules/recaptcha"
|
||||
"code.gitea.io/gitea/modules/session"
|
||||
|
@ -414,6 +415,8 @@ func SignUp(ctx *context.Context) {
|
|||
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
|
||||
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
|
||||
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
|
||||
ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey
|
||||
ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL
|
||||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
// Show Disabled Registration message if DisableRegistration or AllowOnlyExternalRegistration options are true
|
||||
|
@ -435,6 +438,8 @@ func SignUpPost(ctx *context.Context) {
|
|||
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
|
||||
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
|
||||
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
|
||||
ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey
|
||||
ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL
|
||||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
// Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
|
||||
|
@ -458,6 +463,8 @@ func SignUpPost(ctx *context.Context) {
|
|||
valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse)
|
||||
case setting.HCaptcha:
|
||||
valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse)
|
||||
case setting.MCaptcha:
|
||||
valid, err = mcaptcha.Verify(ctx, form.McaptchaResponse)
|
||||
default:
|
||||
ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType))
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue