refactor(emails): restructure email system and add recording notifications
- Move email templates to separate files in src/emails/templates/ - Create new email service architecture (service.js, index.js) - Add recording suggestions email template for matching notifications - Integrate email notifications with matching system (sends when suggestions created) - Update controllers (auth.js, user.js) to use new email module - Update tests to use new email module path - Remove deprecated src/utils/email.js Features: - Template-based email system for easy editing - Automatic email notifications when recording assignments are made - Clean separation between template logic and sending logic - Graceful error handling for AWS SES failures
This commit is contained in:
82
backend/src/emails/templates/password-reset.js
Normal file
82
backend/src/emails/templates/password-reset.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Email template for password reset
|
||||
* Sends secure password reset link to users
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate password reset email content
|
||||
* @param {Object} data - Template data
|
||||
* @param {string} data.firstName - User's first name
|
||||
* @param {string} data.resetLink - Full password reset URL with token
|
||||
* @returns {Object} - Email content with subject, htmlBody, textBody
|
||||
*/
|
||||
function generatePasswordResetEmail(data) {
|
||||
const { firstName, resetLink } = data;
|
||||
|
||||
const subject = 'Reset your spotlight.cam password';
|
||||
|
||||
const htmlBody = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; color: #333; }
|
||||
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
|
||||
.header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center; border-radius: 8px 8px 0 0; }
|
||||
.content { background: #f9fafb; padding: 30px; border-radius: 0 0 8px 8px; }
|
||||
.button { display: inline-block; background: #667eea; color: white; padding: 14px 30px; text-decoration: none; border-radius: 6px; margin: 20px 0; font-weight: 600; }
|
||||
.footer { text-align: center; color: #666; font-size: 14px; margin-top: 30px; }
|
||||
.warning { background: #fef3c7; border-left: 4px solid #f59e0b; padding: 15px; margin: 20px 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>🔐 Password Reset</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h2>Hi ${firstName || 'there'}! 👋</h2>
|
||||
<p>We received a request to reset your password for your spotlight.cam account.</p>
|
||||
|
||||
<a href="${resetLink}" class="button">Reset Password</a>
|
||||
|
||||
<p style="font-size: 14px; color: #666;">This link will expire in 1 hour.</p>
|
||||
|
||||
<div class="warning">
|
||||
<strong>⚠️ Security Notice</strong><br>
|
||||
If you didn't request this password reset, please ignore this email. Your password will remain unchanged.
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>spotlight.cam - P2P video exchange for dance events</p>
|
||||
<p>This is an automated email. Please do not reply.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
const textBody = `
|
||||
Hi ${firstName || 'there'}!
|
||||
|
||||
We received a request to reset your password for your spotlight.cam account.
|
||||
|
||||
Click this link to reset your password:
|
||||
${resetLink}
|
||||
|
||||
This link will expire in 1 hour.
|
||||
|
||||
⚠️ Security Notice
|
||||
If you didn't request this password reset, please ignore this email. Your password will remain unchanged.
|
||||
|
||||
---
|
||||
spotlight.cam - P2P video exchange for dance events
|
||||
This is an automated email. Please do not reply.
|
||||
`;
|
||||
|
||||
return { subject, htmlBody, textBody };
|
||||
}
|
||||
|
||||
module.exports = { generatePasswordResetEmail };
|
||||
Reference in New Issue
Block a user