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:
95
src/templates/email/admin-notification.html
Normal file
95
src/templates/email/admin-notification.html
Normal file
@@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>New Contact Form Submission</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.header {
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
.content {
|
||||
background-color: #f8fafc;
|
||||
padding: 20px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-top: none;
|
||||
border-radius: 0 0 8px 8px;
|
||||
}
|
||||
.field {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.field-label {
|
||||
font-weight: 600;
|
||||
color: #4b5563;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.field-value {
|
||||
background-color: white;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
.message-content {
|
||||
white-space: pre-wrap;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e2e8f0;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 20px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
font-size: 0.9em;
|
||||
color: #6b7280;
|
||||
}
|
||||
.meta-info {
|
||||
font-size: 0.85em;
|
||||
color: #6b7280;
|
||||
margin-top: 20px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>New Contact Form Submission</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="field">
|
||||
<div class="field-label">Name</div>
|
||||
<div class="field-value">{{name}}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="field-label">Email</div>
|
||||
<div class="field-value">{{email}}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="field-label">Message</div>
|
||||
<div class="message-content">{{message}}</div>
|
||||
</div>
|
||||
<div class="meta-info">
|
||||
<div><strong>IP Address:</strong> {{ipAddress}}</div>
|
||||
<div><strong>User Agent:</strong> {{userAgent}}</div>
|
||||
<div><strong>Time:</strong> {{time}}</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>This message was sent from the contact form on {{websiteName}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
1
src/templates/email/manual-review.html
Normal file
1
src/templates/email/manual-review.html
Normal file
@@ -0,0 +1 @@
|
||||
<p><strong>Email:</strong> {{email}}</p><p><strong>Message:</strong> {{message}}</p><p><strong>Justification:</strong> {{justification}}</p>
|
81
src/templates/email/user-confirmation.html
Normal file
81
src/templates/email/user-confirmation.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Thank you for your message</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.header {
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
.content {
|
||||
background-color: #f8fafc;
|
||||
padding: 20px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-top: none;
|
||||
border-radius: 0 0 8px 8px;
|
||||
}
|
||||
.message {
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e2e8f0;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 20px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
font-size: 0.9em;
|
||||
color: #6b7280;
|
||||
}
|
||||
.button {
|
||||
display: inline-block;
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
text-decoration: none;
|
||||
border-radius: 6px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.button:hover {
|
||||
background-color: #1d4ed8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Thank you for your message</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Dear {{name}},</p>
|
||||
<p>Thank you for contacting {{websiteName}}. We have received your message and will get back to you as soon as possible.</p>
|
||||
|
||||
<div class="message">
|
||||
<h3>Your Message:</h3>
|
||||
<p>{{message}}</p>
|
||||
</div>
|
||||
|
||||
<p>If you have any additional information to share, please don't hesitate to reply to this email.</p>
|
||||
|
||||
<a href="https://www.365devnet.eu" class="button">Visit Our Website</a>
|
||||
|
||||
<div class="footer">
|
||||
<p>Best regards,<br>{{websiteName}} Team</p>
|
||||
<p><small>This is an automated message, please do not reply directly to this email.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user