diff --git a/services/context/captcha.go b/services/context/captcha.go index 8ae8bdcae3..bf8b18f79c 100644 --- a/services/context/captcha.go +++ b/services/context/captcha.go @@ -5,6 +5,7 @@ package context import ( "fmt" + "math/rand" "sync" "forgejo.org/modules/base" @@ -55,7 +56,9 @@ func GetImageCaptcha() string { imageCaptchaOnce.Do(func() { captcha.SetCustomStore(&imageCaptchaStore{c: cache.GetCache()}) }) - return captcha.New() + + length := 4 + rand.Intn(2) + return captcha.NewLen(length) } // SetCaptchaData sets common captcha data diff --git a/templates/user/auth/captcha.tmpl b/templates/user/auth/captcha.tmpl index b2deb5a2c9..906786e4c8 100644 --- a/templates/user/auth/captcha.tmpl +++ b/templates/user/auth/captcha.tmpl @@ -1,7 +1,7 @@ {{if .EnableCaptcha}}{{if eq .CaptchaType "image"}}
- {{ctx.Locale.Tr + {{ctx.Locale.Tr
diff --git a/web_src/css/form.css b/web_src/css/form.css index 3a53b6d8f2..679bed1575 100644 --- a/web_src/css/form.css +++ b/web_src/css/form.css @@ -626,3 +626,7 @@ input:-webkit-autofill:active, width: 100% !important; } } + +.captcha-img { + width: min(30em, 100%); +} diff --git a/web_src/css/markup/dark.css b/web_src/css/markup/dark.css index 700a48518e..f6db0c1df4 100644 --- a/web_src/css/markup/dark.css +++ b/web_src/css/markup/dark.css @@ -11,3 +11,12 @@ .markup [href$="#dark-mode-only"] { display: unset; } + +/* + The reason we're doing this here, is because dark templates always use this file, and there's no other way to detect dark theme. + Third party templates may not, but that doesn't really matter, since you can't change the theme logged out. +*/ + +.captcha-img { + filter: invert(); +}