summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-27 22:56:54 +0800
committerGitHub <noreply@github.com>2021-01-27 22:56:54 +0800
commit41c0776568b3fa1bf825439103085146260e16a8 (patch)
tree84237872a82c15ec666a760dd648474fd6ff9ccb /routers
parent669ff8e9b1c15d24dd30852588c2dbb3d82e0cd9 (diff)
downloadgitea-41c0776568b3fa1bf825439103085146260e16a8.tar.gz
gitea-41c0776568b3fa1bf825439103085146260e16a8.zip
Fix captcha (#14488)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers')
-rw-r--r--routers/routes/web.go4
-rw-r--r--routers/user/auth.go5
-rw-r--r--routers/user/auth_openid.go2
3 files changed, 10 insertions, 1 deletions
diff --git a/routers/routes/web.go b/routers/routes/web.go
index 6b6322f048..cbd7c0b7ca 100644
--- a/routers/routes/web.go
+++ b/routers/routes/web.go
@@ -161,7 +161,9 @@ func WebRoutes() *web.Route {
mailer.InitMailRender(templates.Mailer())
- r.Use(captcha.Captchaer(context.GetImageCaptcha()))
+ if setting.Service.EnableCaptcha {
+ r.Use(captcha.Captchaer(context.GetImageCaptcha()))
+ }
// Removed: toolbox.Toolboxer middleware will provide debug informations which seems unnecessary
r.Use(context.Contexter())
// Removed: SetAutoHead allow a get request redirect to head if get method is not exist
diff --git a/routers/user/auth.go b/routers/user/auth.go
index 909d0a2ee5..bb877767ae 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -747,6 +747,7 @@ func LinkAccount(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("link_account")
ctx.Data["LinkAccountMode"] = true
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha && setting.Service.RequireExternalRegistrationCaptcha
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
@@ -800,6 +801,7 @@ func LinkAccountPostSignIn(ctx *context.Context) {
ctx.Data["LinkAccountModeSignIn"] = true
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha && setting.Service.RequireExternalRegistrationCaptcha
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration
@@ -885,6 +887,7 @@ func LinkAccountPostRegister(ctx *context.Context) {
ctx.Data["LinkAccountModeRegister"] = true
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha && setting.Service.RequireExternalRegistrationCaptcha
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration
@@ -1063,6 +1066,7 @@ func SignUp(ctx *context.Context) {
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
@@ -1083,6 +1087,7 @@ func SignUpPost(ctx *context.Context) {
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
diff --git a/routers/user/auth_openid.go b/routers/user/auth_openid.go
index 1efcc7eda8..3f5c9f7248 100644
--- a/routers/user/auth_openid.go
+++ b/routers/user/auth_openid.go
@@ -329,6 +329,7 @@ func RegisterOpenID(ctx *context.Context) {
ctx.Data["PageIsOpenIDRegister"] = true
ctx.Data["EnableOpenIDSignUp"] = setting.Service.EnableOpenIDSignUp
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
@@ -360,6 +361,7 @@ func RegisterOpenIDPost(ctx *context.Context) {
ctx.Data["EnableOpenIDSignUp"] = setting.Service.EnableOpenIDSignUp
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
+ ctx.Data["Captcha"] = context.GetImageCaptcha()
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey