refactor: move go-chi/captcha into Gitea (#39529)

The `gitea.com/go-chi/captcha` package only exists for Gitea,
so it moves into `modules/imagecaptcha`.

- Reloading an expired challenge shows a new image instead of a broken one
- Every answer is consumed on its first check
- OpenID registration stops after a failed captcha

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwindandwxiaoguang authored and GitHub committed 2026-10-02 22:21:41 +08:00
1 parent e6ffbea888
commit 873efed5a6
17 files changed
+656 -59

No files matched your search

+7
View File
@@ -1,6 +1,13 @@
import {isDarkTheme} from '../utils.ts';
import {registerGlobalEventFunc} from '../modules/observer.ts';
export async function initCaptcha() {
registerGlobalEventFunc('click', 'onImageCaptchaReload', (img: HTMLImageElement) => {
const url = new URL(img.src);
url.searchParams.set('reload', String(Date.now()));
img.src = url.href;
});
const captchaEl = document.querySelector('#captcha');
if (!captchaEl) return;