fix: enhance email verification protection by ensuring DOM manipulation only occurs in the browser
This commit is contained in:
@@ -189,29 +189,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add global CSS to prevent any missed interactions
|
// Add global CSS to prevent any missed interactions
|
||||||
const style = document.createElement('style');
|
if (document) {
|
||||||
style.id = 'email-verification-protection';
|
const style = document.createElement('style');
|
||||||
style.textContent = `
|
style.id = 'email-verification-protection';
|
||||||
body:not(.email-verified) button:not([data-verification-modal] button),
|
style.textContent = `
|
||||||
body:not(.email-verified) a:not([data-verification-modal] a),
|
body:not(.email-verified) button:not([data-verification-modal] button),
|
||||||
body:not(.email-verified) input:not([data-verification-modal] input),
|
body:not(.email-verified) a:not([data-verification-modal] a),
|
||||||
body:not(.email-verified) textarea:not([data-verification-modal] textarea),
|
body:not(.email-verified) input:not([data-verification-modal] input),
|
||||||
body:not(.email-verified) [contenteditable="true"]:not([data-verification-modal] [contenteditable]) {
|
body:not(.email-verified) textarea:not([data-verification-modal] textarea),
|
||||||
pointer-events: none !important;
|
body:not(.email-verified) [contenteditable="true"]:not([data-verification-modal] [contenteditable]) {
|
||||||
opacity: 0.5 !important;
|
pointer-events: none !important;
|
||||||
user-select: none !important;
|
opacity: 0.5 !important;
|
||||||
}
|
user-select: none !important;
|
||||||
`;
|
}
|
||||||
document.head.appendChild(style);
|
`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBodyClass() {
|
function updateBodyClass() {
|
||||||
if (browser) {
|
if (!browser) {
|
||||||
if ($profile.is_email_verified) {
|
return;
|
||||||
document.body.classList.add('email-verified');
|
}
|
||||||
} else {
|
|
||||||
document.body.classList.remove('email-verified');
|
if ($profile.is_email_verified) {
|
||||||
}
|
document.body.classList.add('email-verified');
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove('email-verified');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,13 +260,15 @@
|
|||||||
if (domObserver) domObserver.disconnect();
|
if (domObserver) domObserver.disconnect();
|
||||||
|
|
||||||
// Clean up protection styles
|
// Clean up protection styles
|
||||||
const style = document.getElementById('email-verification-protection');
|
if (browser) {
|
||||||
if (style) style.remove();
|
const style = document?.getElementById('email-verification-protection');
|
||||||
|
if (style) style.remove();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$: open = Boolean(!$profile.is_email_verified && !!$profile.id && !!$currentOrg.id);
|
$: open = Boolean(!$profile.is_email_verified && !!$profile.id && !!$currentOrg.id);
|
||||||
$: open && sendVerificationCode();
|
$: open && sendVerificationCode();
|
||||||
$: updateBodyClass();
|
$: if (browser) updateBodyClass();
|
||||||
|
|
||||||
// Console warning for developers trying to bypass
|
// Console warning for developers trying to bypass
|
||||||
$: if (browser && !$profile.is_email_verified && $profile.id) {
|
$: if (browser && !$profile.is_email_verified && $profile.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user