Initial upload
This commit is contained in:
1 parent
b0bf3b7167
commit
a022f29e34
65 files changed
+46484
-4339
No files matched your search
+279
-86
@@ -1,13 +1,17 @@
|
||||
<% const loginBackgroundType=(branding && branding.loginBackgroundType) ? branding.loginBackgroundType : 'video' ; const
|
||||
loginBackgroundUrl='/auth-assets/background' ; const protectedLoginWatermarkUrl='/auth-assets/watermark' ; const
|
||||
loginBackgroundMimeType=(branding && branding.loginBackgroundMimeType) ? branding.loginBackgroundMimeType
|
||||
: 'video/webm' ; %>
|
||||
: 'video/webm' ; const loginRequiresTwoFactor=typeof requiresTwoFactor !== 'undefined' && !!requiresTwoFactor; const
|
||||
loginEmailValue=typeof loginEmail !== 'undefined' ? String(loginEmail || '') : ''; const
|
||||
loginExternalCaptchaAvailable=typeof externalCaptchaAvailable !== 'undefined' ? !!externalCaptchaAvailable : !!useExternalCaptcha; const
|
||||
loginCaptchaChallengeActive=!!useExternalCaptcha || !!showLocalCaptcha; %>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ro">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Login - <%= (branding && branding.appName) ? branding.appName : 'Panel' %></title>
|
||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha384-nRgPTkuX86pH8yjPJUAFuASXQSSl2/bBUiNV47vSYpKFxHJhbcrGnmlYpYJMeD7a" crossorigin="anonymous" referrerpolicy="no-referrer">
|
||||
<link id="favicon" rel="icon" type="image/webp" sizes="16x16"
|
||||
href="<%= (branding && branding.faviconUrl) ? branding.faviconUrl : '/auth-assets/favicon' %>" />
|
||||
@@ -75,7 +79,7 @@
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="<%= loginBackgroundType === 'image' && loginBackgroundUrl ? 'login-body--image' : '' %>">
|
||||
<body class="<%= [loginBackgroundType === 'image' && loginBackgroundUrl ? 'login-body--image' : '', loginRequiresTwoFactor ? 'login-has-2fa' : ''].filter(Boolean).join(' ') %>">
|
||||
<div id="toastHost" class="toast-host" aria-live="polite" aria-atomic="true"></div>
|
||||
|
||||
<script nonce="<%= cspNonce %>">
|
||||
@@ -116,22 +120,24 @@
|
||||
</video>
|
||||
<% } %>
|
||||
|
||||
<form method="POST" action="/login" class="login-form">
|
||||
<form method="POST" action="/login" class="login-form" data-requires-two-factor="<%= loginRequiresTwoFactor ? 'true' : 'false' %>">
|
||||
<input type="text" name="company" tabindex="-1" autocomplete="off" aria-hidden="true" hidden>
|
||||
<input type="hidden" name="botProof" id="botProofInput" value="<%= botProofSeed || '' %>" autocomplete="off">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>" autocomplete="off">
|
||||
<div class="input-holder">
|
||||
<i class="input-icon fa-solid fa-envelope" aria-hidden="true"></i>
|
||||
<input class="login-input" type="email" name="email" placeholder="Email" required />
|
||||
<input class="login-input" type="email" name="email" placeholder="Email" value="<%= loginEmailValue %>" required />
|
||||
</div>
|
||||
<div class="input-holder">
|
||||
<i class="input-icon fa-solid fa-lock" aria-hidden="true"></i>
|
||||
<input class="login-input" type="password" name="password" placeholder="Password" required />
|
||||
</div>
|
||||
<div class="input-holder">
|
||||
<div class="input-holder login-two-factor-field" id="loginTwoFactorField" aria-hidden="<%= loginRequiresTwoFactor ? 'false' : 'true' %>">
|
||||
<i class="input-icon fa-solid fa-fingerprint" aria-hidden="true"></i>
|
||||
<input class="login-input" type="text" name="code" placeholder="2FA Code" required />
|
||||
<input class="login-input" type="text" name="code" id="loginTwoFactorCode" placeholder="2FA Code" maxlength="6"
|
||||
inputmode="numeric" autocomplete="one-time-code" <%= loginRequiresTwoFactor ? 'required' : 'disabled' %> />
|
||||
</div>
|
||||
<a class="forgot-password" href="/forgot-password">Forgot password?</a>
|
||||
|
||||
<input type="hidden" name="captchaToken" id="captchaTokenInput" value="" />
|
||||
<button type="submit" class="get-started">
|
||||
@@ -139,16 +145,15 @@
|
||||
<img class="get-started__logo" src="/auth-assets/logo" alt="D Logo" draggable="false" />
|
||||
<span>Panel</span>
|
||||
</button>
|
||||
<a class="forgot-password" href="/forgot-password">Forgot password?</a>
|
||||
<div class="circle-icon">
|
||||
<i class="fa-solid fa-arrow-right-to-bracket circle-icon__glyph"></i>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="captchaModal" class="captcha-modal<%= (useExternalCaptcha || showLocalCaptcha) ? ' show' : '' %>"
|
||||
<div id="captchaModal" class="captcha-modal<%= loginCaptchaChallengeActive ? ' show' : '' %>"
|
||||
data-provider="<%= (externalCaptchaProvider || 'recaptcha').toLowerCase() %>"
|
||||
data-challenge="<%= (useExternalCaptcha || showLocalCaptcha) ? '1' : '0' %>"
|
||||
aria-hidden="<%= (useExternalCaptcha || showLocalCaptcha) ? 'false' : 'true' %>">
|
||||
data-challenge="<%= loginCaptchaChallengeActive ? '1' : '0' %>"
|
||||
aria-hidden="<%= loginCaptchaChallengeActive ? 'false' : 'true' %>">
|
||||
<div class="captcha-modal__backdrop"></div>
|
||||
<div class="captcha-modal__card">
|
||||
<div class="captcha-modal__title">
|
||||
@@ -158,6 +163,7 @@
|
||||
<div class="captcha-modal__widget">
|
||||
<div id="recaptchaWidget" hidden></div>
|
||||
<div id="cf-turnstile" hidden></div>
|
||||
<div id="hcaptchaWidget" hidden></div>
|
||||
</div>
|
||||
<% if (showLocalCaptcha && captchaQuestion) { %>
|
||||
<div id="localCaptchaUI" class="local-captcha" data-token="<%= captchaQuestion.token %>"
|
||||
@@ -206,13 +212,13 @@
|
||||
<script nonce="<%= cspNonce %>">
|
||||
(() => {
|
||||
const cfg = {
|
||||
enabled: <%- useExternalCaptcha ? "true" : "false" %>,
|
||||
enabled: <%- loginExternalCaptchaAvailable ? "true" : "false" %>,
|
||||
required: <%- externalCaptchaAutoStart ? "true" : "false" %>,
|
||||
provider: <%- JSON.stringify((externalCaptchaProvider || "recaptcha").toLowerCase()) %>,
|
||||
siteKey: <%- JSON.stringify(externalCaptchaSiteKey || "") %>,
|
||||
hasError: <%- error ? "true" : "false" %>,
|
||||
showLocal: <%- showLocalCaptcha ? "true" : "false" %>,
|
||||
challengeActive: <%- (useExternalCaptcha || showLocalCaptcha) ? "true" : "false" %>,
|
||||
challengeActive: <%- loginCaptchaChallengeActive ? "true" : "false" %>,
|
||||
};
|
||||
|
||||
const form = document.querySelector("form");
|
||||
@@ -220,11 +226,13 @@
|
||||
const tokenInput = document.getElementById("captchaTokenInput");
|
||||
const recaptchaHost = document.getElementById("recaptchaWidget");
|
||||
const turnstileHost = document.getElementById("cf-turnstile");
|
||||
const hcaptchaHost = document.getElementById("hcaptchaWidget");
|
||||
const statusEl = modal ? modal.querySelector(".captcha-modal__desc") : null;
|
||||
const defaultStatusText = statusEl ? statusEl.textContent : "";
|
||||
|
||||
let recaptchaId = null;
|
||||
let turnstileId = null;
|
||||
let hcaptchaId = null;
|
||||
let started = false;
|
||||
let timeoutHandle = null;
|
||||
|
||||
@@ -237,6 +245,10 @@
|
||||
const enableForm = () => {
|
||||
if (!form) return;
|
||||
form.querySelectorAll("input, button").forEach(el => { el.disabled = false; });
|
||||
const loginTwoFactorInput = document.getElementById("loginTwoFactorCode");
|
||||
if (loginTwoFactorInput && form.dataset.requiresTwoFactor !== "true") {
|
||||
loginTwoFactorInput.disabled = true;
|
||||
}
|
||||
form.classList.remove("login-form--blocked");
|
||||
};
|
||||
|
||||
@@ -249,6 +261,7 @@
|
||||
if (modal) {
|
||||
modal.classList.remove("show");
|
||||
modal.dataset.challenge = "0";
|
||||
modal.setAttribute("aria-hidden", "true");
|
||||
}
|
||||
enableForm();
|
||||
if (timeoutHandle) {
|
||||
@@ -267,26 +280,68 @@
|
||||
}
|
||||
};
|
||||
|
||||
const resetCaptchaWidget = () => {
|
||||
tokenInput.value = "";
|
||||
try {
|
||||
if (recaptchaId !== null && window.grecaptcha && typeof window.grecaptcha.reset === "function") {
|
||||
window.grecaptcha.reset(recaptchaId);
|
||||
}
|
||||
} catch { }
|
||||
try {
|
||||
if (turnstileId !== null && window.turnstile && typeof window.turnstile.reset === "function") {
|
||||
window.turnstile.reset(turnstileId);
|
||||
}
|
||||
} catch { }
|
||||
try {
|
||||
if (hcaptchaId !== null && window.hcaptcha && typeof window.hcaptcha.reset === "function") {
|
||||
window.hcaptcha.reset(hcaptchaId);
|
||||
}
|
||||
} catch { }
|
||||
};
|
||||
|
||||
async function verifyCaptchaToken(token) {
|
||||
tokenInput.value = token || "";
|
||||
if (timeoutHandle) { clearTimeout(timeoutHandle); timeoutHandle = null; }
|
||||
if (statusEl) statusEl.textContent = "Finalizing sign in...";
|
||||
try {
|
||||
const resp = await fetch("/api/captcha/verify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ token }),
|
||||
credentials: "same-origin",
|
||||
});
|
||||
const data = await resp.json().catch(() => ({}));
|
||||
if (resp.ok && data.ok) {
|
||||
if (data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
return;
|
||||
}
|
||||
hideModal();
|
||||
return;
|
||||
}
|
||||
resetCaptchaWidget();
|
||||
if (data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
return;
|
||||
}
|
||||
if (statusEl) statusEl.textContent = data.error || "Captcha verification failed. Try again.";
|
||||
} catch {
|
||||
resetCaptchaWidget();
|
||||
if (statusEl) statusEl.textContent = "Network error. Try again.";
|
||||
}
|
||||
}
|
||||
|
||||
function renderRecaptcha() {
|
||||
if (!cfg.enabled || recaptchaId !== null) return recaptchaId;
|
||||
if (!window.grecaptcha || typeof window.grecaptcha.render !== "function") return null;
|
||||
if (turnstileHost) turnstileHost.hidden = true;
|
||||
if (hcaptchaHost) hcaptchaHost.hidden = true;
|
||||
if (recaptchaHost) recaptchaHost.hidden = false;
|
||||
recaptchaId = window.grecaptcha.render("recaptchaWidget", {
|
||||
sitekey: cfg.siteKey,
|
||||
size: "normal",
|
||||
theme: "dark",
|
||||
callback: (token) => {
|
||||
tokenInput.value = token || "";
|
||||
if (timeoutHandle) { clearTimeout(timeoutHandle); timeoutHandle = null; }
|
||||
fetch("/api/captcha/verify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ token }),
|
||||
credentials: "same-origin",
|
||||
}).catch(() => { });
|
||||
hideModal();
|
||||
},
|
||||
callback: verifyCaptchaToken,
|
||||
"expired-callback": () => { tokenInput.value = ""; },
|
||||
"error-callback": () => { tokenInput.value = ""; },
|
||||
});
|
||||
@@ -305,22 +360,13 @@
|
||||
if (!cfg.enabled || turnstileId !== null) return turnstileId;
|
||||
if (!window.turnstile || typeof window.turnstile.render !== "function") return null;
|
||||
if (recaptchaHost) recaptchaHost.hidden = true;
|
||||
if (hcaptchaHost) hcaptchaHost.hidden = true;
|
||||
if (turnstileHost) turnstileHost.hidden = false;
|
||||
turnstileId = window.turnstile.render("#cf-turnstile", {
|
||||
sitekey: cfg.siteKey,
|
||||
size: "normal",
|
||||
theme: "dark",
|
||||
callback: (token) => {
|
||||
tokenInput.value = token || "";
|
||||
if (timeoutHandle) { clearTimeout(timeoutHandle); timeoutHandle = null; }
|
||||
fetch("/api/captcha/verify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ token }),
|
||||
credentials: "same-origin",
|
||||
}).catch(() => { });
|
||||
hideModal();
|
||||
},
|
||||
callback: verifyCaptchaToken,
|
||||
"expired-callback": () => { tokenInput.value = ""; },
|
||||
"error-callback": () => { tokenInput.value = ""; },
|
||||
});
|
||||
@@ -335,60 +381,203 @@
|
||||
if (attempt < 50) setTimeout(() => ensureTurnstile(attempt + 1), 200);
|
||||
}
|
||||
|
||||
function renderHcaptcha() {
|
||||
if (!cfg.enabled || hcaptchaId !== null) return hcaptchaId;
|
||||
if (!window.hcaptcha || typeof window.hcaptcha.render !== "function") return null;
|
||||
if (recaptchaHost) recaptchaHost.hidden = true;
|
||||
if (turnstileHost) turnstileHost.hidden = true;
|
||||
if (hcaptchaHost) hcaptchaHost.hidden = false;
|
||||
hcaptchaId = window.hcaptcha.render("hcaptchaWidget", {
|
||||
sitekey: cfg.siteKey,
|
||||
size: "normal",
|
||||
theme: "dark",
|
||||
callback: verifyCaptchaToken,
|
||||
"expired-callback": () => { tokenInput.value = ""; },
|
||||
"error-callback": () => { tokenInput.value = ""; },
|
||||
});
|
||||
if (timeoutHandle) { clearTimeout(timeoutHandle); timeoutHandle = null; }
|
||||
resetStatus();
|
||||
return hcaptchaId;
|
||||
}
|
||||
|
||||
function ensureHcaptcha(attempt = 0) {
|
||||
if (hcaptchaId === null) renderHcaptcha();
|
||||
if (hcaptchaId !== null) return;
|
||||
if (attempt < 50) setTimeout(() => ensureHcaptcha(attempt + 1), 200);
|
||||
}
|
||||
|
||||
function startCaptchaFlow() {
|
||||
started = true;
|
||||
if (modal) {
|
||||
modal.dataset.challenge = "1";
|
||||
modal.setAttribute("aria-hidden", "false");
|
||||
}
|
||||
showModal();
|
||||
resetStatus();
|
||||
if (timeoutHandle) clearTimeout(timeoutHandle);
|
||||
timeoutHandle = setTimeout(markTimeout, 30000);
|
||||
if (["cloudflare", "turnstile", "cf"].includes(cfg.provider)) return ensureTurnstile();
|
||||
return ensureRecaptcha();
|
||||
}
|
||||
timeoutHandle = setTimeout(markTimeout, 30000);
|
||||
if (!cfg.enabled) return;
|
||||
if (["cloudflare", "turnstile", "cf"].includes(cfg.provider)) return ensureTurnstile();
|
||||
if (["hcaptcha", "h"].includes(cfg.provider)) return ensureHcaptcha();
|
||||
return ensureRecaptcha();
|
||||
}
|
||||
|
||||
if (form) {
|
||||
form.addEventListener("submit", (e) => {
|
||||
if (modal && modal.dataset.challenge === "1") {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
if (cfg.enabled && !tokenInput.value) startCaptchaFlow();
|
||||
return false;
|
||||
}
|
||||
if (cfg.enabled && !tokenInput.value) {
|
||||
e.preventDefault();
|
||||
startCaptchaFlow();
|
||||
return false;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
if (modal && modal.dataset.challenge === "1") {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
if (cfg.enabled && !tokenInput.value) startCaptchaFlow();
|
||||
return false;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
if (cfg.challengeActive) {
|
||||
disableForm();
|
||||
if (cfg.enabled && !started) startCaptchaFlow();
|
||||
} else if (cfg.enabled && cfg.required && !started) {
|
||||
startCaptchaFlow();
|
||||
}
|
||||
if (cfg.challengeActive) {
|
||||
disableForm();
|
||||
if (cfg.enabled && !started) startCaptchaFlow();
|
||||
} else if (cfg.enabled && cfg.required && !started) {
|
||||
startCaptchaFlow();
|
||||
}
|
||||
|
||||
window.initRecaptcha = function initRecaptcha() {
|
||||
if (!cfg.enabled) return;
|
||||
ensureRecaptcha();
|
||||
};
|
||||
|
||||
window.initTurnstile = function initTurnstile() {
|
||||
if (!cfg.enabled) return;
|
||||
ensureTurnstile();
|
||||
};
|
||||
window.initTurnstile = function initTurnstile() {
|
||||
if (!cfg.enabled) return;
|
||||
ensureTurnstile();
|
||||
};
|
||||
|
||||
window.__adCaptchaResolved = hideModal;
|
||||
})();
|
||||
</script>
|
||||
<% if (useExternalCaptcha) { %>
|
||||
<% if (["cloudflare","turnstile","cf"].includes((externalCaptchaProvider || "" ).toLowerCase())) { %>
|
||||
<script nonce="<%= cspNonce %>"
|
||||
src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=initTurnstile&render=explicit" async
|
||||
defer></script>
|
||||
<% } else { %>
|
||||
<script nonce="<%= cspNonce %>"
|
||||
src="https://www.google.com/recaptcha/api.js?onload=initRecaptcha&render=explicit" async
|
||||
window.initHcaptcha = function initHcaptcha() {
|
||||
if (!cfg.enabled) return;
|
||||
ensureHcaptcha();
|
||||
};
|
||||
|
||||
window.__adCaptchaResolved = (data) => {
|
||||
if (data && data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
return;
|
||||
}
|
||||
hideModal();
|
||||
};
|
||||
window.__adStartCaptchaFlow = startCaptchaFlow;
|
||||
})();
|
||||
</script>
|
||||
<script nonce="<%= cspNonce %>">
|
||||
(() => {
|
||||
const form = document.querySelector("form.login-form");
|
||||
if (!form || !window.fetch) return;
|
||||
|
||||
const twoFactorField = document.getElementById("loginTwoFactorField");
|
||||
const twoFactorInput = document.getElementById("loginTwoFactorCode");
|
||||
const csrfInput = form.querySelector('input[name="_csrf"]');
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
const toastHost = document.getElementById("toastHost");
|
||||
|
||||
function showLoginToast(text, duration = 4200) {
|
||||
if (!toastHost || !text) return;
|
||||
const toast = document.createElement("div");
|
||||
toast.className = "toast";
|
||||
toast.innerHTML = '<div class="toast-inner"><div class="toast-msg"></div><div class="toast-bar"></div></div>';
|
||||
toast.querySelector(".toast-msg").textContent = text;
|
||||
toastHost.appendChild(toast);
|
||||
requestAnimationFrame(() => toast.classList.add("toast-show"));
|
||||
setTimeout(() => toast.classList.add("toast-hide"), Math.max(0, duration - 320));
|
||||
setTimeout(() => toast.remove(), duration + 450);
|
||||
}
|
||||
|
||||
function setTwoFactorRequired(required) {
|
||||
form.dataset.requiresTwoFactor = required ? "true" : "false";
|
||||
document.body?.classList.toggle("login-has-2fa", !!required);
|
||||
if (twoFactorField) {
|
||||
twoFactorField.setAttribute("aria-hidden", required ? "false" : "true");
|
||||
}
|
||||
if (twoFactorInput) {
|
||||
twoFactorInput.required = !!required;
|
||||
twoFactorInput.disabled = !required;
|
||||
if (!required) twoFactorInput.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
setTwoFactorRequired(form.dataset.requiresTwoFactor === "true");
|
||||
|
||||
twoFactorInput?.addEventListener("input", () => {
|
||||
twoFactorInput.value = twoFactorInput.value.replace(/\D/g, "").slice(0, 6);
|
||||
});
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
if (e.defaultPrevented) return;
|
||||
e.preventDefault();
|
||||
|
||||
if (submitBtn) submitBtn.disabled = true;
|
||||
let keepSubmitDisabled = false;
|
||||
|
||||
try {
|
||||
const body = new URLSearchParams(new FormData(form));
|
||||
const res = await fetch(form.action || "/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
},
|
||||
credentials: "same-origin",
|
||||
body,
|
||||
});
|
||||
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (data.csrfToken && csrfInput) csrfInput.value = data.csrfToken;
|
||||
|
||||
if (data.requires2FA) {
|
||||
setTwoFactorRequired(true);
|
||||
showLoginToast(data.error || "Enter your 2FA code to continue.");
|
||||
setTimeout(() => twoFactorInput?.focus(), 40);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.captchaRequired) {
|
||||
keepSubmitDisabled = true;
|
||||
if (data.useExternalCaptcha && typeof window.__adStartCaptchaFlow === "function") {
|
||||
window.__adStartCaptchaFlow();
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.ok && data.ok) {
|
||||
window.location.href = data.redirect || "/";
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.status === 403 && !data.error) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
showLoginToast(data.error || "Invalid credentials");
|
||||
} catch (err) {
|
||||
showLoginToast("Network error. Try again.");
|
||||
} finally {
|
||||
if (submitBtn && !keepSubmitDisabled) submitBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<% if (loginExternalCaptchaAvailable) { %>
|
||||
<% if (["cloudflare","turnstile","cf"].includes((externalCaptchaProvider || "" ).toLowerCase())) { %>
|
||||
<script nonce="<%= cspNonce %>"
|
||||
src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=initTurnstile&render=explicit" async
|
||||
defer></script>
|
||||
<% } else if (["hcaptcha","h"].includes((externalCaptchaProvider || "" ).toLowerCase())) { %>
|
||||
<script nonce="<%= cspNonce %>"
|
||||
src="https://js.hcaptcha.com/1/api.js?onload=initHcaptcha&render=explicit" async
|
||||
defer></script>
|
||||
<% } else { %>
|
||||
<script nonce="<%= cspNonce %>"
|
||||
src="https://www.google.com/recaptcha/api.js?onload=initRecaptcha&render=explicit" async
|
||||
defer></script>
|
||||
<% } %>
|
||||
<% } %>
|
||||
@@ -444,19 +633,23 @@
|
||||
})
|
||||
.then(function (resp) { return resp.json(); })
|
||||
.then(function (data) {
|
||||
if (data.ok && data.done) {
|
||||
setLocalStatus("Verified!", "success");
|
||||
if (typeof window.__adCaptchaResolved === "function") window.__adCaptchaResolved();
|
||||
return;
|
||||
}
|
||||
if (data.ok && !data.done && data.question) {
|
||||
selected.clear();
|
||||
rebuildGrid(data.question);
|
||||
setLocalStatus("", "");
|
||||
submitBtn.disabled = false;
|
||||
return;
|
||||
}
|
||||
setLocalStatus(data.error === "expired" ? "Expired. Reloading..." : "Incorrect selection. Reloading...", "error");
|
||||
if (data.ok && data.done) {
|
||||
setLocalStatus("Verified!", "success");
|
||||
if (typeof window.__adCaptchaResolved === "function") window.__adCaptchaResolved(data);
|
||||
return;
|
||||
}
|
||||
if (data.ok && !data.done && data.question) {
|
||||
selected.clear();
|
||||
rebuildGrid(data.question);
|
||||
setLocalStatus("", "");
|
||||
submitBtn.disabled = false;
|
||||
return;
|
||||
}
|
||||
if (!data.ok && data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
return;
|
||||
}
|
||||
setLocalStatus(data.error === "expired" ? "Expired. Reloading..." : "Incorrect selection. Reloading...", "error");
|
||||
setTimeout(function () { window.location.reload(); }, 1800);
|
||||
})
|
||||
.catch(function () {
|
||||
@@ -533,7 +726,7 @@
|
||||
|
||||
<script nonce="<%= cspNonce %>">
|
||||
(function () {
|
||||
var challengeActive = <%- (showLocalCaptcha || (useExternalCaptcha && externalCaptchaAutoStart)) ? "true" : "false" %>;
|
||||
var challengeActive = <%- loginCaptchaChallengeActive ? "true" : "false" %>;
|
||||
if (!challengeActive) return;
|
||||
|
||||
var modal = document.getElementById("captchaModal");
|
||||
|
||||
Reference in new issue
Block a user