aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/auth/openid.go
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-08-10 13:20:10 +0000
committerGitHub <noreply@github.com>2022-08-10 15:20:10 +0200
commit58de07e5fd14c23dd4c4a315b8c5b3fb3219f66a (patch)
treecec2e02c494e19a42bc6095c480d93354259b669 /routers/web/auth/openid.go
parent452272c0384d7033ffde18bcb1167e8e49ff598c (diff)
downloadgitea-58de07e5fd14c23dd4c4a315b8c5b3fb3219f66a.tar.gz
gitea-58de07e5fd14c23dd4c4a315b8c5b3fb3219f66a.zip
Add support mCaptcha as captcha provider (#20458)
https://mcaptcha.org/ Co-authored-by: Felipe Leopoldo Sologuren GutiƩrrez <fsologureng@users.noreply.github.com>
Diffstat (limited to 'routers/web/auth/openid.go')
-rw-r--r--routers/web/auth/openid.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go
index 32ae91da47..3b1065189d 100644
--- a/routers/web/auth/openid.go
+++ b/routers/web/auth/openid.go
@@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/hcaptcha"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/mcaptcha"
"code.gitea.io/gitea/modules/recaptcha"
"code.gitea.io/gitea/modules/session"
"code.gitea.io/gitea/modules/setting"
@@ -341,6 +342,8 @@ func RegisterOpenID(ctx *context.Context) {
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey
+ ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL
ctx.Data["OpenID"] = oid
userName, _ := ctx.Session.Get("openid_determined_username").(string)
if userName != "" {
@@ -372,6 +375,8 @@ func RegisterOpenIDPost(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["OpenID"] = oid
if setting.Service.AllowOnlyInternalRegistration {
@@ -397,6 +402,12 @@ func RegisterOpenIDPost(ctx *context.Context) {
return
}
valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse)
+ case setting.MCaptcha:
+ if err := ctx.Req.ParseForm(); err != nil {
+ ctx.ServerError("", err)
+ return
+ }
+ valid, err = mcaptcha.Verify(ctx, form.McaptchaResponse)
default:
ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType))
return