mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
added more checks to email verif
This commit is contained in:
@@ -146,6 +146,18 @@ function isProfane(str) {
|
||||
const csrfHeader = document.querySelector('meta[name="_csrf_header"]').getAttribute('content');
|
||||
|
||||
try {
|
||||
const checkResponse = await fetch(`/api/email/check?email=${encodeURIComponent(email)}`, {
|
||||
method: "POST",
|
||||
headers: { [csrfHeader]: csrfToken }
|
||||
});
|
||||
|
||||
if (!checkResponse.ok) {
|
||||
const errorText = await checkResponse.text();
|
||||
passwordError.style.color = "red";
|
||||
passwordError.textContent = errorText || "Invalid Email Detected.";
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem("pendingEmail", email);
|
||||
sessionStorage.setItem("pendingUser", JSON.stringify({
|
||||
username: name,
|
||||
@@ -154,10 +166,16 @@ function isProfane(str) {
|
||||
role: "ROLE_USER"
|
||||
}));
|
||||
|
||||
await fetch(`/api/email/send?email=${encodeURIComponent(email)}`, {
|
||||
const sendResponse = await fetch(`/api/email/send?email=${encodeURIComponent(email)}`, {
|
||||
method: "POST",
|
||||
headers: { [csrfHeader]: csrfToken }
|
||||
});
|
||||
|
||||
if (!sendResponse.ok) {
|
||||
passwordError.style.color = "red";
|
||||
passwordError.textContent = "Failed to send verification email. Please check your address.";
|
||||
return;
|
||||
}
|
||||
|
||||
passwordError.style.color = "green";
|
||||
passwordError.textContent = "Check your email for a verification code...";
|
||||
@@ -170,7 +188,7 @@ function isProfane(str) {
|
||||
passwordError.textContent = "Could not connect to the server.";
|
||||
console.error("Request error:", error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user