Files
roast_command_center/public/js/forgot.js
T
snowspeeder 59645e59b5 Add green-bean inventory and cupping features
Ports inventory management and SCA-style cupping scoring from
hope_roaster: lot tracking with audit-logged consumption, cupping
sessions with server-authoritative scoring and a live radar chart,
and links from the planner (draw-from-lot, open-cupping-session).

Also fixes the Blend/Single-origin toggle layout, replaces tooltips
with an in-context "why" teaching layer, and stages the planner UI
into pre-roast vs. post-roast phases.
2026-07-30 14:47:15 -04:00

31 lines
1.0 KiB
JavaScript

const form = document.querySelector("#forgot-form");
const message = document.querySelector("#message");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const submitButton = form.querySelector("button[type=submit]");
submitButton.disabled = true;
try {
const response = await fetch("/api/auth/forgot", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(Object.fromEntries(new FormData(form))),
});
if (response.status === 429) {
message.textContent = "Too many requests. Try again in a few minutes.";
message.className = "auth-message error";
return;
}
// Always show the same message, whether or not the account exists.
message.textContent =
"If that email has an account, a reset link is on its way.";
message.className = "auth-message info";
form.reset();
} catch {
message.textContent = "Could not reach the server. Try again shortly.";
message.className = "auth-message error";
} finally {
submitButton.disabled = false;
}
});