Merge pull request 'Make the captcha shorter' (#6) from captcha-length into forgejo
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

Reviewed-on: #6
This commit is contained in:
Minecon724 2025-06-05 09:48:02 +02:00
commit ebe3f887ae

View file

@ -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