Release v2.2: admin auth settings, Passkey RP ID, Cloudflare and Google captcha
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{% if captcha_config %}
|
||||
<div class="form-group captcha-widget">
|
||||
{% if captcha_config.provider == 'turnstile' %}
|
||||
<div class="cf-turnstile" data-sitekey="{{ captcha_config.site_key }}"></div>
|
||||
{% elif captcha_config.provider == 'recaptcha_v2' %}
|
||||
<div class="g-recaptcha" data-sitekey="{{ captcha_config.site_key }}"></div>
|
||||
{% elif captcha_config.provider == 'recaptcha_v3' %}
|
||||
<input type="hidden" name="g-recaptcha-response" id="recaptchaV3Token" value="">
|
||||
<p class="folder-hint">Защита reCAPTCHA v3 активна</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,36 @@
|
||||
{% if captcha_config %}
|
||||
{% if captcha_config.provider == 'turnstile' %}
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
||||
{% elif captcha_config.provider == 'recaptcha_v2' %}
|
||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||
{% elif captcha_config.provider == 'recaptcha_v3' %}
|
||||
<script src="https://www.google.com/recaptcha/api.js?render={{ captcha_config.site_key }}"></script>
|
||||
<script>
|
||||
(function () {
|
||||
function bindRecaptchaV3() {
|
||||
const form = document.querySelector(".auth-form");
|
||||
const tokenInput = document.getElementById("recaptchaV3Token");
|
||||
if (!form || !tokenInput || !window.grecaptcha) return;
|
||||
|
||||
form.addEventListener("submit", function (event) {
|
||||
if (tokenInput.value) return;
|
||||
event.preventDefault();
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute("{{ captcha_config.site_key }}", { action: "{{ captcha_config.action }}" })
|
||||
.then(function (token) {
|
||||
tokenInput.value = token;
|
||||
form.submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (window.grecaptcha) {
|
||||
bindRecaptchaV3();
|
||||
} else {
|
||||
window.addEventListener("load", bindRecaptchaV3);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user