Functional Verification

This commit is contained in:
durn
2026-04-28 22:35:00 -06:00
parent cd35378ffa
commit 229bc6bf69
14 changed files with 297 additions and 78 deletions
@@ -146,27 +146,25 @@ function isProfane(str) {
const csrfHeader = document.querySelector('meta[name="_csrf_header"]').getAttribute('content');
try {
const response = await fetch("/api/users", {
sessionStorage.setItem("pendingEmail", email);
sessionStorage.setItem("pendingUser", JSON.stringify({
username: name,
email: email,
hashedpassword: password,
role: "ROLE_USER"
}));
await fetch(`/api/email/send?email=${encodeURIComponent(email)}`, {
method: "POST",
headers: {
[csrfHeader]: csrfToken,
"Content-Type": "application/json"
},
body: JSON.stringify(userData)
headers: { [csrfHeader]: csrfToken }
});
if (response.ok) {
passwordError.style.color = "green";
passwordError.textContent = "Account created successfully. Redirecting to login...";
setTimeout(function () {
window.location.href = "/login";
}, 1500);
} else {
const errorText = await response.text();
passwordError.style.color = "red";
passwordError.textContent = "Account creation failed. Please try a different username or email.";
console.error("Create account failed:", errorText);
}
passwordError.style.color = "green";
passwordError.textContent = "Check your email for a verification code...";
setTimeout(function () {
window.location.href = "/verify";
}, 1500);
} catch (error) {
passwordError.style.color = "red";
passwordError.textContent = "Could not connect to the server.";