mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-15 06:26:16 +01:00
0404662e99
- This is a fork of https://github.com/dchest/captcha, as
https://gitea.com/go-chi/captcha is a fork of
github.com/go-macaron/captcha which is a fork (although not properly
credited) of a older version of https://github.com/dchest/captcha. Hence
why I've just forked the original.
- The fork includes some QoL improvements (uses standard library for
determistic RNG instead of rolling your own crypto), and removal of
audio support (500KiB unused data that bloated the binary otherwise).
Flips the image over the x-asis.
47270f2b55
..main
- This move is needed for the next commit, because
gitea.com/go-chi/captcha included the gitea.com/go-chi/cache dependency.
30 lines
1.6 KiB
Go HTML Template
30 lines
1.6 KiB
Go HTML Template
{{if .EnableCaptcha}}{{if eq .CaptchaType "image"}}
|
|
<div class="inline field tw-text-center">
|
|
<input type="hidden" name="img-captcha-id" value="{{.Captcha}}">
|
|
<img style="transform: scaleX(-1)" onclick="this.src=`{{AppSubUrl}}/captcha/{{.Captcha}}.png?reload=${Date.now()}`" class="captcha-img" src="{{AppSubUrl}}/captcha/{{.Captcha}}.png">
|
|
</div>
|
|
<div class="required field {{if .Err_Captcha}}error{{end}}">
|
|
<label for="captcha">{{ctx.Locale.Tr "captcha"}}</label>
|
|
<input id="captcha" name="img-captcha-response" autocomplete="off">
|
|
</div>
|
|
{{else if eq .CaptchaType "recaptcha"}}
|
|
<div class="inline field tw-text-center required">
|
|
<div id="captcha" data-captcha-type="g-recaptcha" class="g-recaptcha-style" data-sitekey="{{.RecaptchaSitekey}}"></div>
|
|
</div>
|
|
<script src='{{URLJoin .RecaptchaURL "api.js"}}'></script>
|
|
{{else if eq .CaptchaType "hcaptcha"}}
|
|
<div class="inline field tw-text-center required">
|
|
<div id="captcha" data-captcha-type="h-captcha" class="h-captcha-style" data-sitekey="{{.HcaptchaSitekey}}"></div>
|
|
</div>
|
|
<script src='https://hcaptcha.com/1/api.js'></script>
|
|
{{else if eq .CaptchaType "mcaptcha"}}
|
|
<div class="inline field tw-text-center">
|
|
<div class="m-captcha-style" id="mcaptcha__widget-container"></div>
|
|
<div id="captcha" data-captcha-type="m-captcha" data-sitekey="{{.McaptchaSitekey}}" data-instance-url="{{.McaptchaURL}}"></div>
|
|
</div>
|
|
{{else if eq .CaptchaType "cfturnstile"}}
|
|
<div class="inline field tw-text-center">
|
|
<div id="captcha" data-captcha-type="cf-turnstile" data-sitekey="{{.CfTurnstileSitekey}}"></div>
|
|
</div>
|
|
<script src='https://challenges.cloudflare.com/turnstile/v0/api.js'></script>
|
|
{{end}}{{end}}
|