fix: enhance email verification protection by ensuring DOM manipulation only occurs in the browser

This commit is contained in:
Rotimi Best
2025-12-04 00:00:48 +01:00
parent 25d1a8d710
commit 964c036252
@@ -189,6 +189,7 @@
}
// Add global CSS to prevent any missed interactions
if (document) {
const style = document.createElement('style');
style.id = 'email-verification-protection';
style.textContent = `
@@ -204,16 +205,19 @@
`;
document.head.appendChild(style);
}
}
function updateBodyClass() {
if (browser) {
if (!browser) {
return;
}
if ($profile.is_email_verified) {
document.body.classList.add('email-verified');
} else {
document.body.classList.remove('email-verified');
}
}
}
const sendVerificationCode = async () => {
if (isSent) return;
@@ -256,13 +260,15 @@
if (domObserver) domObserver.disconnect();
// Clean up protection styles
const style = document.getElementById('email-verification-protection');
if (browser) {
const style = document?.getElementById('email-verification-protection');
if (style) style.remove();
}
});
$: open = Boolean(!$profile.is_email_verified && !!$profile.id && !!$currentOrg.id);
$: open && sendVerificationCode();
$: updateBodyClass();
$: if (browser) updateBodyClass();
// Console warning for developers trying to bypass
$: if (browser && !$profile.is_email_verified && $profile.id) {