password reset

This commit is contained in:
oliver
2026-06-08 09:37:14 -03:00
parent 53803e9d12
commit ccc3f92d04
3 changed files with 224 additions and 0 deletions
+40
View File
@@ -34,6 +34,8 @@ const AUTH_URL =
"https://n8n.derez.ai/webhook/e256310a-6627-45ba-a221-599751943fe6";
const ACCOUNT_PASSWORD_URL =
"https://n8n.derez.ai/webhook/4644f196-a31c-4d1a-b76e-03e9afe39302";
const PW_RESET_URL =
"https://n8n.derez.ai/webhook/c2ce0eba-eb26-405d-8a90-8d982ec30698";
/* ─── State ─────────────────────────────────────────────────── */
let currentEmail = null;
@@ -129,6 +131,8 @@ function switchAuthTab(tab) {
document.getElementById("signin-error").style.display = "none";
document.getElementById("signup-error").style.display = "none";
document.getElementById("signup-success").style.display = "none";
const _rpw = document.getElementById("reset-pw-wrap");
if (_rpw) _rpw.style.display = "none";
}
/* ═══════════════════════════════════════════════════════════════
@@ -182,6 +186,7 @@ async function doSignIn() {
loadAgents();
} catch (err) {
showAuthError("signin-error", err.message);
showResetOption();
} finally {
btnReset(btn);
}
@@ -1824,6 +1829,41 @@ function showAuthError(id, msg) {
function hideAuthError(id) {
document.getElementById(id).style.display = "none";
if (id === "signin-error") {
const wrap = document.getElementById("reset-pw-wrap");
if (wrap) wrap.style.display = "none";
}
}
function showResetOption() {
const wrap = document.getElementById("reset-pw-wrap");
if (!wrap) return;
// Return to idle state in case it was previously used
document.getElementById("reset-pw-idle").style.display = "flex";
document.getElementById("reset-pw-sent").style.display = "none";
wrap.style.display = "block";
}
async function sendPasswordReset() {
const email = document.getElementById("signin-email").value.trim();
if (!email) {
toast("Enter your email address above first.", "warning");
return;
}
const btn = document.getElementById("reset-pw-btn");
btnLoad(btn, "Sending…");
try {
await fetch(PW_RESET_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email }),
});
} catch (_) {
// Always show sent — never reveal whether the address exists
} finally {
document.getElementById("reset-pw-idle").style.display = "none";
document.getElementById("reset-pw-sent").style.display = "flex";
}
}
/* ═══════════════════════════════════════════════════════════════