From b8b32773b6d12b7f2f8804f7e18548fffc4a8456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 5 Jul 2023 15:02:03 +0200 Subject: [PATCH] add bot check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörg Thalheim --- routers/web/auth/auth.go | 5 +++++ services/forms/user_form.go | 1 + templates/user/auth/signup_inner.tmpl | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 3bf133f56..1c37dca09 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -411,6 +411,11 @@ func SignUpPost(ctx *context.Context) { context.SetCaptchaData(ctx) ctx.Data["PageIsSignUp"] = true + if strings.ToLower(form.Notabot) != "clan" { + ctx.Error(http.StatusForbidden) + return + } + // Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true if setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration { ctx.Error(http.StatusForbidden) diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 1f5abf94e..196300a14 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -94,6 +94,7 @@ type RegisterForm struct { UserName string `binding:"Required;Username;MaxSize(40)"` Email string `binding:"Required;MaxSize(254)"` Password string `binding:"MaxSize(255)"` + Notabot string `binding:"Required"` Retype string } diff --git a/templates/user/auth/signup_inner.tmpl b/templates/user/auth/signup_inner.tmpl index 8dfcb7b7d..3e5ced297 100644 --- a/templates/user/auth/signup_inner.tmpl +++ b/templates/user/auth/signup_inner.tmpl @@ -24,6 +24,11 @@ +
+ +
+
+ {{if not .DisablePassword}}
-- 2.41.0