/** * Update email templates with professional styling matching account creation confirmation */ // Email template color scheme - matching the account creation template const COLORS = { // Brand colors primary: '#8a4dea', primaryDark: '#7c3aed', primaryLight: '#a366f0', primarySubtle: '#faf8ff', primaryAccent: '#f3f0ff', // Neutral colors textPrimary: '#0f172a', textSecondary: '#334155', textMuted: '#64748b', textLight: '#94a3b8', textOnDark: '#cbd5e1', // Background colors bgPrimary: '#ffffff', bgSecondary: '#f8fafc', bgDark: '#1e293b', // Border colors borderLight: '#e2e8f0', borderSubtle: '#e9e5f5', // State colors warning: '#f59e0b', warningBg: '#fffbeb', warningText: '#92400e', success: '#10b981', successBg: '#f0fdf4', successText: '#166534', }; exports.up = async function(knex) { // Update portal-invitation template const portalInvitationHtml = ` Portal Access Invitation

Welcome to Your Customer Portal

You're invited to access your account

Hello {{contactName}},

Great news! You've been invited to access the customer portal for {{companyName}}. This secure portal gives you instant access to:

🎯 What You Can Access

✓ View and track your support tickets

✓ Review project updates and documentation

✓ Communicate directly with your support team

Experience seamless service management with our intuitive portal. Everything you need to stay informed and connected, all in one secure location.
Set Up Your Portal Access

Or copy and paste this link into your browser:

⏰ Time-Sensitive Invitation

This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access.

Need Assistance?

Email: {{companyLocationEmail}}

Phone: {{companyLocationPhone}}

Our support team is ready to help you get started.

`; const portalInvitationText = ` Welcome to Your Customer Portal Hello {{contactName}}, Great news! You've been invited to access the customer portal for {{companyName}}. This secure portal gives you instant access to: ✓ View and track your support tickets ✓ Review project updates and documentation ✓ Communicate directly with your support team SET UP YOUR PORTAL ACCESS: {{portalLink}} ⏰ TIME-SENSITIVE: This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access. NEED ASSISTANCE? Email: {{companyLocationEmail}} Phone: {{companyLocationPhone}} Our support team is ready to help you get started. --- This email was sent to {{contactName}} as part of your portal access setup. If you didn't expect this invitation, please contact us at {{companyLocationEmail}}. © {{currentYear}} {{companyName}}. All rights reserved. `; // Update password-reset template const passwordResetHtml = ` Password Reset Request

Password Reset Request

Secure password recovery for your account

Hello {{userName}},

We received a request to reset the password for your account associated with {{email}}.

🔐 Account Security Check

Requested at: Just now

Account email: {{email}}

Valid for: {{expirationTime}}

To create a new password for your account, click the button below:

Reset Your Password

Or copy and paste this link into your browser:

⚠️ Important Security Information

What's Next?

  1. Click the reset button above or use the provided link
  2. Create a strong, unique password for your account
  3. You'll be automatically logged in after resetting
  4. All existing sessions will be terminated for security
  5. Consider enabling two-factor authentication for added protection

Need Help?

If you're having trouble resetting your password, our support team is here to help.

Contact Support: {{supportEmail}}

`; const passwordResetText = ` Password Reset Request Hello {{userName}}, We received a request to reset the password for your account associated with {{email}}. ACCOUNT SECURITY CHECK: • Account email: {{email}} • Valid for: {{expirationTime}} RESET YOUR PASSWORD: Click the link below to create a new password for your account: {{resetLink}} ⚠️ IMPORTANT SECURITY INFORMATION: • This password reset link will expire in {{expirationTime}} • For security reasons, this link can only be used once • If you didn't request this reset, please ignore this email • Your password won't change until you create a new one ✅ AFTER RESETTING YOUR PASSWORD: • You'll be automatically logged in to your account • All your existing sessions will be terminated for security • Consider enabling two-factor authentication for added security NEED HELP? If you're having trouble resetting your password, our support team is here to help. Contact Support: {{supportEmail}} --- This is an automated security email sent to {{email}}. For your security, we never include passwords in emails. © {{currentYear}} {{clientName}}. All rights reserved. `; // Update portal-invitation template await knex('system_email_templates') .where({ name: 'portal-invitation' }) .update({ html_content: portalInvitationHtml, text_content: portalInvitationText, updated_at: new Date() }); // Update password-reset template await knex('system_email_templates') .where({ name: 'password-reset' }) .update({ html_content: passwordResetHtml, text_content: passwordResetText, updated_at: new Date() }); }; exports.down = async function(knex) { // Revert portal-invitation to previous version const previousPortalInvitationHtml = `

Portal Access Invitation

Hello {{contactName}},

You have been invited to access the customer portal for {{companyName}}. This portal will give you access to view your tickets, invoices, and other important information.

Getting Started

Click the button below to set up your portal account. You'll be able to create a secure password and access your information immediately.

Set Up Portal Access

If the button doesn't work, you can also copy and paste this link into your browser:
{{portalLink}}

Important: This invitation link will expire in {{expirationTime}}. Please complete your account setup before then.

Questions? Contact us:

Email: {{companyLocationEmail}}
Phone: {{companyLocationPhone}}

If you didn't expect this invitation, please contact us at {{companyLocationEmail}}.

© {{currentYear}} {{companyName}}. All rights reserved.

`; const previousPortalInvitationText = ` Portal Access Invitation - {{companyName}} Hello {{contactName}}, You have been invited to access the customer portal for {{companyName}}. This portal will give you access to view your tickets, invoices, and other important information. Getting Started: Click the link below to set up your portal account. You'll be able to create a secure password and access your information immediately. Portal Setup Link: {{portalLink}} IMPORTANT: This invitation link will expire in {{expirationTime}}. Please complete your account setup before then. Questions? Contact us: Email: {{companyLocationEmail}} Phone: {{companyLocationPhone}} If you didn't expect this invitation, please contact us at {{companyLocationEmail}}. © {{currentYear}} {{companyName}}. All rights reserved. `; // Revert password-reset to previous version const previousPasswordResetHtml = ` Password Reset Request

Password Reset Request

Hello {{userName}},

We received a request to reset your password for your account associated with {{email}}.

To reset your password, please click the button below:

Reset Your Password

Or copy and paste this link into your browser:

{{resetLink}}

Important: This password reset link will expire in {{expirationTime}}. If you did not request a password reset, please ignore this email or contact support if you have concerns.

For security reasons, this link can only be used once.

`; const previousPasswordResetText = ` Password Reset Request Hello {{userName}}, We received a request to reset your password for your account associated with {{email}}. To reset your password, please click the link below: {{resetLink}} IMPORTANT: This password reset link will expire in {{expirationTime}}. If you did not request a password reset, please ignore this email or contact support if you have concerns. For security reasons, this link can only be used once. If you're having trouble, please contact support at {{supportEmail}} © {{currentYear}} {{clientName}}. All rights reserved. `; await knex('system_email_templates') .where({ name: 'portal-invitation' }) .update({ html_content: previousPortalInvitationHtml, text_content: previousPortalInvitationText, updated_at: new Date() }); await knex('system_email_templates') .where({ name: 'password-reset' }) .update({ html_content: previousPasswordResetHtml, text_content: previousPasswordResetText, updated_at: new Date() }); };