Refactor CookieBanner and Contact API for improved functionality and security
- Removed localStorage fallback from CookieBanner, simplifying consent management. - Refactored manual review email handling in the Contact API to utilize HTML templates for better structure and security. - Enhanced email content generation by escaping HTML special characters and using template files for dynamic data insertion.
This commit is contained in:
@@ -69,19 +69,6 @@ const t = getTranslation(lang);
|
||||
return;
|
||||
}
|
||||
|
||||
// Also check localStorage as a fallback
|
||||
try {
|
||||
if (localStorage && localStorage.getItem('cookieConsentAccepted') === 'true') {
|
||||
cookieBanner.style.display = 'none';
|
||||
// Also set the cookie for future visits
|
||||
setCookie('cookieConsentAccepted', 'true', 365);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error accessing localStorage:', e);
|
||||
// Continue checking cookies
|
||||
}
|
||||
|
||||
// Show the banner
|
||||
cookieBanner.style.display = 'block';
|
||||
|
||||
@@ -93,17 +80,9 @@ const t = getTranslation(lang);
|
||||
|
||||
// Handle accept button click
|
||||
acceptButton.addEventListener('click', () => {
|
||||
// Store consent in cookie (primary storage)
|
||||
// Store consent in cookie
|
||||
setCookie('cookieConsentAccepted', 'true', 365);
|
||||
|
||||
// Also store in localStorage as backup
|
||||
try {
|
||||
localStorage.setItem('cookieConsentAccepted', 'true');
|
||||
} catch (e) {
|
||||
console.error('Error setting localStorage:', e);
|
||||
// Continue with cookie storage
|
||||
}
|
||||
|
||||
// Hide the banner with animation
|
||||
cookieBanner.classList.add('translate-y-full');
|
||||
|
||||
|
Reference in New Issue
Block a user