/** * Add system authentication email templates to database * * This migration adds email_verification, password_reset, and portal-invitation * templates to system_email_templates for all supported languages. * * This allows us to remove hardcoded templates from i18nSystemEmailService * and manage all templates consistently through the database. */ exports.up = async function(knex) { console.log('Adding system authentication email templates...'); // Drop old unique constraint on name only if it exists await knex.raw('ALTER TABLE system_email_templates DROP CONSTRAINT IF EXISTS system_email_templates_name_unique'); await knex.raw('ALTER TABLE system_email_templates DROP CONSTRAINT IF EXISTS system_email_templates_name_key'); // Ensure composite unique constraint exists await knex.raw('ALTER TABLE system_email_templates DROP CONSTRAINT IF EXISTS system_email_templates_name_language_key'); await knex.raw('ALTER TABLE system_email_templates ADD CONSTRAINT system_email_templates_name_language_key UNIQUE (name, language_code)'); // Fetch or create notification subtype IDs const subtypeIds = {}; // Ensure Authentication category exists let authCategory = await knex('notification_categories') .where({ name: 'Authentication' }) .first(); if (!authCategory) { [authCategory] = await knex('notification_categories') .insert({ name: 'Authentication', description: 'Authentication and security notifications', is_enabled: true, is_default_enabled: true }) .returning('*'); } const existingSubtypes = ['email-verification', 'password-reset', 'portal-invitation']; const existingSubtypeDescriptions = { 'email-verification': 'Email verification instructions for new users', 'password-reset': 'Password reset instructions for users', 'portal-invitation': 'Invitation email for customer portal access' }; for (const name of existingSubtypes) { let subtype = await knex('notification_subtypes') .where({ name }) .first(); if (!subtype) { [subtype] = await knex('notification_subtypes') .insert({ category_id: authCategory.id, name, description: existingSubtypeDescriptions[name] ?? name, is_enabled: true, is_default_enabled: true }) .returning('*'); console.log(`✓ Created notification subtype: ${name}`); } subtypeIds[name] = subtype.id; } // Create new subtypes for tenant-recovery and no-account-found if they don't exist const newSubtypes = { 'tenant-recovery': 'Tenant/organization account recovery and login links', 'no-account-found': 'Notification when no account is found for email address' }; for (const [name, description] of Object.entries(newSubtypes)) { let subtype = await knex('notification_subtypes') .where({ name }) .first(); if (!subtype && authCategory) { [subtype] = await knex('notification_subtypes') .insert({ category_id: authCategory.id, name, description, is_enabled: true, is_default_enabled: true }) .returning('*'); console.log(`✓ Created notification subtype: ${name}`); } if (subtype) { subtypeIds[name] = subtype.id; } } console.log('✓ Authentication notification subtypes ready:', Object.keys(subtypeIds)); // Create Tickets and Invoices categories if they don't exist const ticketsCategory = await knex('notification_categories') .where({ name: 'Tickets' }) .first() || (await knex('notification_categories') .insert({ name: 'Tickets', description: 'Notifications related to support tickets', is_enabled: true, is_default_enabled: true }) .returning('*'))[0]; const invoicesCategory = await knex('notification_categories') .where({ name: 'Invoices' }) .first() || (await knex('notification_categories') .insert({ name: 'Invoices', description: 'Notifications related to billing and invoices', is_enabled: true, is_default_enabled: true }) .returning('*'))[0]; // Create ticket notification subtypes if they don't exist const ticketSubtypes = { 'Ticket Assigned': 'When a ticket is assigned to a user', 'Ticket Created': 'When a new ticket is created', 'Ticket Updated': 'When a ticket is modified', 'Ticket Closed': 'When a ticket is closed', 'Ticket Comment Added': 'When a comment is added to a ticket' }; for (const [name, description] of Object.entries(ticketSubtypes)) { let subtype = await knex('notification_subtypes') .where({ name }) .first(); if (!subtype) { [subtype] = await knex('notification_subtypes') .insert({ category_id: ticketsCategory.id, name, description, is_enabled: true, is_default_enabled: true }) .returning('*'); console.log(`✓ Created notification subtype: ${name}`); } subtypeIds[name] = subtype.id; } // Create invoice notification subtypes if they don't exist const invoiceSubtypes = { 'Invoice Generated': 'When a new invoice is generated', 'Payment Received': 'When a payment is received', 'Payment Overdue': 'When an invoice payment is overdue' }; for (const [name, description] of Object.entries(invoiceSubtypes)) { let subtype = await knex('notification_subtypes') .where({ name }) .first(); if (!subtype) { [subtype] = await knex('notification_subtypes') .insert({ category_id: invoicesCategory.id, name, description, is_enabled: true, is_default_enabled: true }) .returning('*'); console.log(`✓ Created notification subtype: ${name}`); } subtypeIds[name] = subtype.id; } console.log('✓ All notification subtypes ready:', Object.keys(subtypeIds)); // Delete ALL existing portal-invitation templates (all languages) // This ensures we update templates with correct styling and variable names console.log('Removing old portal-invitation templates...'); await knex('system_email_templates') .where({ name: 'portal-invitation' }) .del(); console.log('✓ Old portal-invitation templates removed'); // English templates await knex('system_email_templates').insert([ { name: 'email-verification', language_code: 'en', subject: 'Verify your email{{#if registrationClientName}} for {{registrationClientName}}{{/if}}', notification_subtype_id: subtypeIds['email-verification'], html_content: `

Email Verification

Hello,

Please verify your email address by clicking the link below:

Verify Email

Or copy and paste this link into your browser:

{{verificationUrl}}

{{#if expirationTime}}

This link will expire in {{expirationTime}}.

{{/if}}

If you didn't request this email, please ignore it.

© {{currentYear}} {{tenantClientName}}

`, text_content: `Email Verification Please verify your email address by visiting: {{verificationUrl}} {{#if expirationTime}}This link will expire in {{expirationTime}}.{{/if}} If you didn't request this email, please ignore it. © {{currentYear}} {{tenantClientName}}`, notification_subtype_id: subtypeIds['email-verification'] }, { name: 'password-reset', language_code: 'en', subject: 'Password Reset Request', html_content: `

Password Reset

Hello {{userName}},

You requested to reset your password for {{email}}. Click the link below to proceed:

Reset Password

Or copy and paste this link into your browser:

{{resetLink}}

This link will expire in {{expirationTime}}.


If you didn't request this password reset, please ignore this email. Your password will remain unchanged.

{{#if supportEmail}}

Need help? Contact {{supportEmail}}

{{/if}}

© {{currentYear}} {{clientName}}

`, text_content: `Password Reset Request Hello {{userName}}, You requested to reset your password for {{email}}. Visit the following link: {{resetLink}} This link will expire in {{expirationTime}}. If you didn't request this password reset, please ignore this email. {{#if supportEmail}}Need help? Contact {{supportEmail}}{{/if}} © {{currentYear}} {{clientName}}`, notification_subtype_id: subtypeIds['password-reset'] }, { name: 'portal-invitation', language_code: 'en', subject: 'Portal Invitation - {{clientName}}', html_content: ` 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 {{clientName}}. 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: {{clientLocationEmail}}

Phone: {{clientLocationPhone}}

Our support team is ready to help you get started.

`, text_content: `Welcome to Your Customer Portal Hello {{contactName}}, Great news! You've been invited to access the customer portal for {{clientName}}. 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 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: {{portalLink}} ⏰ Time-Sensitive Invitation This invitation link will expire in {{expirationTime}}. Please complete your account setup before then to ensure uninterrupted access. Need Assistance? Email: {{clientLocationEmail}} Phone: {{clientLocationPhone}} 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 {{clientLocationEmail}}. © {{currentYear}} {{clientName}}. All rights reserved.`, notification_subtype_id: subtypeIds['portal-invitation'] }, { name: 'tenant-recovery', language_code: 'en', subject: '{{platformName}} - Your Login Links', html_content: `

{{platformName}}

Hello,

You requested access to your client portal{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}We found {{tenantCount}} organizations associated with your email address.{{else}}Here is your login link:{{/if}}

{{tenantLinksHtml}}

Security Note: If you didn't request these login links, you can safely ignore this email. Your account remains secure.

If you have any questions or need assistance, please contact your organization's support team.

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

This is an automated message. Please do not reply to this email.

`, text_content: `{{platformName}} - Your Login Links Hello, You requested access to your client portal{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}We found {{tenantCount}} organizations associated with your email address.{{else}}Here is your login link:{{/if}} Your Login Links: {{tenantLinksText}} Security Note: If you didn't request these login links, you can safely ignore this email. Your account remains secure. If you have any questions or need assistance, please contact your organization's support team. --- © {{currentYear}} {{platformName}}. All rights reserved. This is an automated message. Please do not reply to this email.`, notification_subtype_id: subtypeIds['tenant-recovery'] }, { name: 'no-account-found', language_code: 'en', subject: '{{platformName}} - Access Request', html_content: `

{{platformName}}

Hello,

We received a request to access the client portal using this email address.

If you have an account with us, you should have received a separate email with your login links. If you didn't receive a login email, it may mean:

Need Help? If you believe you should have access to a client portal, please contact your service provider's support team for assistance.

Security Note: If you didn't request access, you can safely ignore this email.

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

This is an automated message. Please do not reply to this email.

`, text_content: `{{platformName}} - Access Request Hello, We received a request to access the client portal using this email address. If you have an account with us, you should have received a separate email with your login links. If you didn't receive a login email, it may mean: - This email address is not associated with any client portal accounts - Your account may be inactive - The email may have been filtered to your spam folder Need Help? If you believe you should have access to a client portal, please contact your service provider's support team for assistance. Security Note: If you didn't request access, you can safely ignore this email. --- © {{currentYear}} {{platformName}}. All rights reserved. This is an automated message. Please do not reply to this email.`, notification_subtype_id: subtypeIds['no-account-found'] } ]).onConflict(['name', 'language_code']).ignore(); console.log('✓ English system auth templates added (including tenant-recovery)'); // French templates await knex('system_email_templates').insert([ { name: 'email-verification', language_code: 'fr', subject: 'Vérifiez votre email{{#if registrationClientName}} pour {{registrationClientName}}{{/if}}', html_content: `

Vérification d'email

Bonjour,

Veuillez vérifier votre adresse email en cliquant sur le lien ci-dessous :

Vérifier l'email

Ou copiez et collez ce lien dans votre navigateur :

{{verificationUrl}}

{{#if expirationTime}}

Ce lien expirera dans {{expirationTime}}.

{{/if}}

Si vous n'avez pas demandé cet email, veuillez l'ignorer.

© {{currentYear}} {{tenantClientName}}

`, text_content: `Vérification d'email Veuillez vérifier votre adresse email en visitant : {{verificationUrl}} {{#if expirationTime}}Ce lien expirera dans {{expirationTime}}.{{/if}} Si vous n'avez pas demandé cet email, veuillez l'ignorer. © {{currentYear}} {{tenantClientName}}`, notification_subtype_id: subtypeIds['email-verification'] }, { name: 'password-reset', language_code: 'fr', subject: 'Demande de réinitialisation du mot de passe', html_content: `

Réinitialisation du mot de passe

Bonjour {{userName}},

Vous avez demandé à réinitialiser votre mot de passe pour {{email}}. Cliquez sur le lien ci-dessous pour continuer :

Réinitialiser le mot de passe

Ou copiez et collez ce lien dans votre navigateur :

{{resetLink}}

Ce lien expirera dans {{expirationTime}}.


Si vous n'avez pas demandé cette réinitialisation, veuillez ignorer cet email. Votre mot de passe restera inchangé.

{{#if supportEmail}}

Besoin d'aide ? Contactez {{supportEmail}}

{{/if}}

© {{currentYear}} {{clientName}}

`, text_content: `Demande de réinitialisation du mot de passe Bonjour {{userName}}, Vous avez demandé à réinitialiser votre mot de passe pour {{email}}. Visitez le lien suivant : {{resetLink}} Ce lien expirera dans {{expirationTime}}. Si vous n'avez pas demandé cette réinitialisation, veuillez ignorer cet email. {{#if supportEmail}}Besoin d'aide ? Contactez {{supportEmail}}{{/if}} © {{currentYear}} {{clientName}}`, notification_subtype_id: subtypeIds['password-reset'] }, { name: 'portal-invitation', language_code: 'fr', subject: 'Invitation au portail client - {{clientName}}', html_content: ` Invitation d'accès au portail

Bienvenue sur votre portail client

Vous êtes invité à accéder à votre compte

Bonjour {{contactName}},

Excellente nouvelle ! Vous avez été invité à accéder au portail client de {{clientName}}. Ce portail sécurisé vous donne un accès instantané à :

🎯 Ce à quoi vous pouvez accéder

✓ Consulter et suivre vos tickets d'assistance

✓ Examiner les mises à jour et la documentation des projets

✓ Communiquer directement avec votre équipe d'assistance

Profitez d'une gestion de services fluide avec notre portail intuitif. Tout ce dont vous avez besoin pour rester informé et connecté, le tout dans un emplacement sécurisé.
Configurer l'accès à mon portail

Ou copiez et collez ce lien dans votre navigateur :

⏰ Invitation à durée limitée

Ce lien d'invitation expirera dans {{expirationTime}}. Veuillez terminer la configuration de votre compte avant cette échéance pour garantir un accès ininterrompu.

Besoin d'assistance ?

Email : {{clientLocationEmail}}

Téléphone : {{clientLocationPhone}}

Notre équipe d'assistance est prête à vous aider à démarrer.

`, text_content: `Bienvenue sur votre portail client Bonjour {{contactName}}, Excellente nouvelle ! Vous avez été invité à accéder au portail client de {{clientName}}. Ce portail sécurisé vous donne un accès instantané à : ✓ Consulter et suivre vos tickets d'assistance ✓ Examiner les mises à jour et la documentation des projets ✓ Communiquer directement avec votre équipe d'assistance CONFIGURER L'ACCÈS À MON PORTAIL : {{portalLink}} ⏰ DURÉE LIMITÉE : Ce lien d'invitation expirera dans {{expirationTime}}. Veuillez terminer la configuration de votre compte avant cette échéance pour garantir un accès ininterrompu. BESOIN D'ASSISTANCE ? Email : {{clientLocationEmail}} Téléphone : {{clientLocationPhone}} Notre équipe d'assistance est prête à vous aider à démarrer. --- Cet email a été envoyé à {{contactName}} dans le cadre de la configuration de votre accès au portail. Si vous n'attendiez pas cette invitation, veuillez nous contacter à {{clientLocationEmail}}. © {{currentYear}} {{clientName}}. Tous droits réservés. `, notification_subtype_id: subtypeIds['portal-invitation'] }, { name: 'tenant-recovery', language_code: 'fr', subject: '{{platformName}} - Vos liens de connexion', html_content: `

{{platformName}}

Bonjour,

Vous avez demandé l'accès à votre portail{{#if isMultiple}}s{{/if}} client{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}Nous avons trouvé {{tenantCount}} organisations associées à votre adresse e-mail.{{else}}Voici votre lien de connexion :{{/if}}

{{tenantLinksHtml}}

Note de sécurité : Si vous n'avez pas demandé ces liens de connexion, vous pouvez ignorer cet e-mail en toute sécurité. Votre compte reste sécurisé.

Si vous avez des questions ou besoin d'assistance, veuillez contacter l'équipe d'assistance de votre organisation.

© {{currentYear}} {{platformName}}. Tous droits réservés.

Ceci est un message automatisé. Veuillez ne pas répondre à cet e-mail.

`, text_content: `{{platformName}} - Vos liens de connexion Bonjour, Vous avez demandé l'accès à votre portail{{#if isMultiple}}s{{/if}} client{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}Nous avons trouvé {{tenantCount}} organisations associées à votre adresse e-mail.{{else}}Voici votre lien de connexion :{{/if}} Vos liens de connexion : {{tenantLinksText}} Note de sécurité : Si vous n'avez pas demandé ces liens de connexion, vous pouvez ignorer cet e-mail en toute sécurité. Si vous avez des questions ou besoin d'assistance, veuillez contacter l'équipe d'assistance de votre organisation. --- © {{currentYear}} {{platformName}}. Tous droits réservés. Ceci est un message automatisé. Veuillez ne pas répondre à cet e-mail.`, notification_subtype_id: subtypeIds['tenant-recovery'] }, { name: 'no-account-found', language_code: 'fr', subject: '{{platformName}} - Demande d\'accès', html_content: `

{{platformName}}

Bonjour,

Nous avons reçu une demande d'accès au portail client utilisant cette adresse e-mail.

Si vous avez un compte chez nous, vous devriez avoir reçu un e-mail séparé avec vos liens de connexion.

Si vous n'avez pas reçu d'e-mail de connexion, cela peut signifier :

Besoin d'aide ?

Si vous pensez que vous devriez avoir accès à un portail client, veuillez contacter l'équipe d'assistance de votre fournisseur de services pour obtenir de l'aide.

Note de sécurité : Si vous n'avez pas demandé d'accès, vous pouvez ignorer cet e-mail en toute sécurité.

© {{currentYear}} {{platformName}}. Tous droits réservés.

Ceci est un message automatisé. Veuillez ne pas répondre à cet e-mail.

`, text_content: `{{platformName}} - Demande d'accès Bonjour, Nous avons reçu une demande d'accès au portail client utilisant cette adresse e-mail. Si vous avez un compte chez nous, vous devriez avoir reçu un e-mail séparé avec vos liens de connexion. Si vous n'avez pas reçu d'e-mail de connexion, cela peut signifier : - Cette adresse e-mail n'est associée à aucun compte de portail client - Votre compte peut être inactif - L'e-mail peut avoir été filtré vers votre dossier spam Besoin d'aide ? Si vous pensez que vous devriez avoir accès à un portail client, veuillez contacter l'équipe d'assistance de votre fournisseur de services pour obtenir de l'aide. Note de sécurité : Si vous n'avez pas demandé d'accès, vous pouvez ignorer cet e-mail en toute sécurité. --- © {{currentYear}} {{platformName}}. Tous droits réservés. Ceci est un message automatisé. Veuillez ne pas répondre à cet e-mail.`, notification_subtype_id: subtypeIds['no-account-found'] } ]).onConflict(['name', 'language_code']).ignore(); console.log('✓ French system auth templates added'); // Spanish templates await knex('system_email_templates').insert([ { name: 'email-verification', language_code: 'es', subject: 'Verifica tu correo electrónico{{#if registrationClientName}} para {{registrationClientName}}{{/if}}', html_content: `

Verificación de correo electrónico

Hola,

Por favor verifica tu dirección de correo electrónico haciendo clic en el enlace a continuación:

Verificar correo

O copia y pega este enlace en tu navegador:

{{verificationUrl}}

{{#if expirationTime}}

Este enlace expirará en {{expirationTime}}.

{{/if}}

Si no solicitaste este correo, por favor ignóralo.

© {{currentYear}} {{tenantClientName}}

`, text_content: `Verificación de correo electrónico Por favor verifica tu dirección de correo electrónico visitando: {{verificationUrl}} {{#if expirationTime}}Este enlace expirará en {{expirationTime}}.{{/if}} Si no solicitaste este correo, por favor ignóralo. © {{currentYear}} {{tenantClientName}}`, notification_subtype_id: subtypeIds['email-verification'] }, { name: 'password-reset', language_code: 'es', subject: 'Solicitud de restablecimiento de contraseña', html_content: `

Restablecimiento de contraseña

Hola {{userName}},

Has solicitado restablecer tu contraseña para {{email}}. Haz clic en el enlace a continuación para continuar:

Restablecer contraseña

O copia y pega este enlace en tu navegador:

{{resetLink}}

Este enlace expirará en {{expirationTime}}.


Si no solicitaste este restablecimiento, por favor ignora este correo. Tu contraseña permanecerá sin cambios.

{{#if supportEmail}}

¿Necesitas ayuda? Contacta {{supportEmail}}

{{/if}}

© {{currentYear}} {{clientName}}

`, text_content: `Solicitud de restablecimiento de contraseña Hola {{userName}}, Has solicitado restablecer tu contraseña para {{email}}. Visita el siguiente enlace: {{resetLink}} Este enlace expirará en {{expirationTime}}. Si no solicitaste este restablecimiento, por favor ignora este correo. {{#if supportEmail}}¿Necesitas ayuda? Contacta {{supportEmail}}{{/if}} © {{currentYear}} {{clientName}}`, notification_subtype_id: subtypeIds['password-reset'] }, { name: 'portal-invitation', language_code: 'es', subject: 'Invitación al portal del cliente - {{clientName}}', html_content: ` Invitación de acceso al portal

Bienvenido a tu portal del cliente

Estás invitado a acceder a tu cuenta

Hola {{contactName}},

¡Excelentes noticias! Has sido invitado a acceder al portal del cliente de {{clientName}}. Este portal seguro te brinda acceso instantáneo a:

🎯 A qué puedes acceder

✓ Ver y realizar seguimiento de tus tickets de soporte

✓ Revisar actualizaciones y documentación de proyectos

✓ Comunicarte directamente con tu equipo de soporte

Experimenta una gestión de servicios sin interrupciones con nuestro portal intuitivo. Todo lo que necesitas para mantenerte informado y conectado, todo en un lugar seguro.
Configurar el acceso a mi portal

O copia y pega este enlace en tu navegador:

⏰ Invitación con tiempo limitado

Este enlace de invitación expirará en {{expirationTime}}. Por favor, completa la configuración de tu cuenta antes de ese momento para garantizar un acceso ininterrumpido.

¿Necesitas asistencia?

Email: {{clientLocationEmail}}

Teléfono: {{clientLocationPhone}}

Nuestro equipo de soporte está listo para ayudarte a comenzar.

`, text_content: `Bienvenido a tu portal del cliente Hola {{contactName}}, ¡Excelentes noticias! Has sido invitado a acceder al portal del cliente de {{clientName}}. Este portal seguro te brinda acceso instantáneo a: ✓ Ver y realizar seguimiento de tus tickets de soporte ✓ Revisar actualizaciones y documentación de proyectos ✓ Comunicarte directamente con tu equipo de soporte CONFIGURAR EL ACCESO A MI PORTAL: {{portalLink}} ⏰ TIEMPO LIMITADO: Este enlace de invitación expirará en {{expirationTime}}. Por favor, completa la configuración de tu cuenta antes de ese momento para garantizar un acceso ininterrumpido. ¿NECESITAS ASISTENCIA? Email: {{clientLocationEmail}} Teléfono: {{clientLocationPhone}} Nuestro equipo de soporte está listo para ayudarte a comenzar. --- Este correo fue enviado a {{contactName}} como parte de la configuración de tu acceso al portal. Si no esperabas esta invitación, por favor contáctanos en {{clientLocationEmail}}. © {{currentYear}} {{clientName}}. Todos los derechos reservados. `, notification_subtype_id: subtypeIds['portal-invitation'] }, { name: 'tenant-recovery', language_code: 'es', subject: '{{platformName}} - Tus enlaces de inicio de sesión', html_content: `

{{platformName}}

Hola,

Solicitaste acceso a tu portal{{#if isMultiple}}es{{/if}} de cliente{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}Encontramos {{tenantCount}} organizaciones asociadas con tu dirección de correo electrónico.{{else}}Aquí está tu enlace de inicio de sesión:{{/if}}

{{tenantLinksHtml}}

Nota de seguridad: Si no solicitaste estos enlaces de inicio de sesión, puedes ignorar este correo de forma segura. Tu cuenta permanece segura.

Si tienes preguntas o necesitas asistencia, por favor contacta al equipo de soporte de tu organización.

© {{currentYear}} {{platformName}}. Todos los derechos reservados.

Este es un mensaje automático. Por favor no respondas a este correo.

`, text_content: `{{platformName}} - Tus enlaces de inicio de sesión Hola, Solicitaste acceso a tu portal{{#if isMultiple}}es{{/if}} de cliente{{#if isMultiple}}s{{/if}}. {{#if isMultiple}}Encontramos {{tenantCount}} organizaciones asociadas con tu dirección de correo electrónico.{{else}}Aquí está tu enlace de inicio de sesión:{{/if}} Tus enlaces de inicio de sesión: {{tenantLinksText}} Nota de seguridad: Si no solicitaste estos enlaces de inicio de sesión, puedes ignorar este correo de forma segura. Si tienes preguntas o necesitas asistencia, por favor contacta al equipo de soporte de tu organización. --- © {{currentYear}} {{platformName}}. Todos los derechos reservados. Este es un mensaje automático. Por favor no respondas a este correo.`, notification_subtype_id: subtypeIds['tenant-recovery'] }, { name: 'no-account-found', language_code: 'es', subject: '{{platformName}} - Solicitud de acceso', html_content: `

{{platformName}}

Hola,

Recibimos una solicitud para acceder al portal del cliente usando esta dirección de correo electrónico.

Si tienes una cuenta con nosotros, deberías haber recibido un correo separado con tus enlaces de inicio de sesión.

Si no recibiste un correo de inicio de sesión, puede significar:

¿Necesitas ayuda?

Si crees que deberías tener acceso a un portal del cliente, por favor contacta al equipo de soporte de tu proveedor de servicios para obtener ayuda.

Nota de seguridad: Si no solicitaste acceso, puedes ignorar este correo de forma segura.

© {{currentYear}} {{platformName}}. Todos los derechos reservados.

Este es un mensaje automático. Por favor no respondas a este correo.

`, text_content: `{{platformName}} - Solicitud de acceso Hola, Recibimos una solicitud para acceder al portal del cliente usando esta dirección de correo electrónico. Si tienes una cuenta con nosotros, deberías haber recibido un correo separado con tus enlaces de inicio de sesión. Si no recibiste un correo de inicio de sesión, puede significar: - Esta dirección de correo electrónico no está asociada con ninguna cuenta del portal del cliente - Tu cuenta puede estar inactiva - El correo puede haber sido filtrado a tu carpeta de spam ¿Necesitas ayuda? Si crees que deberías tener acceso a un portal del cliente, por favor contacta al equipo de soporte de tu proveedor de servicios para obtener ayuda. Nota de seguridad: Si no solicitaste acceso, puedes ignorar este correo de forma segura. --- © {{currentYear}} {{platformName}}. Todos los derechos reservados. Este es un mensaje automático. Por favor no respondas a este correo.`, notification_subtype_id: subtypeIds['no-account-found'] } ]).onConflict(['name', 'language_code']).ignore(); console.log('✓ Spanish system auth templates added'); // German templates await knex('system_email_templates').insert([ { name: 'email-verification', language_code: 'de', subject: 'Verifizieren Sie Ihre E-Mail{{#if registrationClientName}} für {{registrationClientName}}{{/if}}', html_content: `

E-Mail-Verifizierung

Hallo,

Bitte verifizieren Sie Ihre E-Mail-Adresse, indem Sie auf den untenstehenden Link klicken:

E-Mail verifizieren

Oder kopieren Sie diesen Link in Ihren Browser:

{{verificationUrl}}

{{#if expirationTime}}

Dieser Link läuft in {{expirationTime}} ab.

{{/if}}

Wenn Sie diese E-Mail nicht angefordert haben, ignorieren Sie sie bitte.

© {{currentYear}} {{tenantClientName}}

`, text_content: `E-Mail-Verifizierung Bitte verifizieren Sie Ihre E-Mail-Adresse unter: {{verificationUrl}} {{#if expirationTime}}Dieser Link läuft in {{expirationTime}} ab.{{/if}} Wenn Sie diese E-Mail nicht angefordert haben, ignorieren Sie sie bitte. © {{currentYear}} {{tenantClientName}}`, notification_subtype_id: subtypeIds['email-verification'] }, { name: 'password-reset', language_code: 'de', subject: 'Passwort-Zurücksetzungsanfrage', html_content: `

Passwort zurücksetzen

Hallo {{userName}},

Sie haben angefordert, Ihr Passwort für {{email}} zurückzusetzen. Klicken Sie auf den untenstehenden Link, um fortzufahren:

Passwort zurücksetzen

Oder kopieren Sie diesen Link in Ihren Browser:

{{resetLink}}

Dieser Link läuft in {{expirationTime}} ab.


Wenn Sie diese Zurücksetzung nicht angefordert haben, ignorieren Sie diese E-Mail bitte. Ihr Passwort bleibt unverändert.

{{#if supportEmail}}

Benötigen Sie Hilfe? Kontaktieren Sie {{supportEmail}}

{{/if}}

© {{currentYear}} {{clientName}}

`, text_content: `Passwort-Zurücksetzungsanfrage Hallo {{userName}}, Sie haben angefordert, Ihr Passwort für {{email}} zurückzusetzen. Besuchen Sie folgenden Link: {{resetLink}} Dieser Link läuft in {{expirationTime}} ab. Wenn Sie diese Zurücksetzung nicht angefordert haben, ignorieren Sie diese E-Mail bitte. {{#if supportEmail}}Benötigen Sie Hilfe? Kontaktieren Sie {{supportEmail}}{{/if}} © {{currentYear}} {{clientName}}`, notification_subtype_id: subtypeIds['password-reset'] }, { name: 'portal-invitation', language_code: 'de', subject: 'Kundenportal-Einladung - {{clientName}}', html_content: ` Portalzugangs-Einladung

Willkommen in Ihrem Kundenportal

Sie sind eingeladen, auf Ihr Konto zuzugreifen

Hallo {{contactName}},

Großartige Neuigkeiten! Sie wurden eingeladen, auf das Kundenportal von {{clientName}} zuzugreifen. Dieses sichere Portal bietet Ihnen sofortigen Zugang zu:

🎯 Worauf Sie zugreifen können

✓ Ihre Support-Tickets anzeigen und verfolgen

✓ Projekt-Updates und Dokumentation einsehen

✓ Direkt mit Ihrem Support-Team kommunizieren

Erleben Sie nahtloses Service-Management mit unserem intuitiven Portal. Alles, was Sie brauchen, um informiert und verbunden zu bleiben, an einem sicheren Ort.
Meinen Portalzugang einrichten

Oder kopieren Sie diesen Link in Ihren Browser:

⏰ Zeitlich begrenzte Einladung

Dieser Einladungslink läuft in {{expirationTime}} ab. Bitte schließen Sie die Einrichtung Ihres Kontos vorher ab, um einen unterbrechungsfreien Zugang zu gewährleisten.

Benötigen Sie Unterstützung?

E-Mail: {{clientLocationEmail}}

Telefon: {{clientLocationPhone}}

Unser Support-Team ist bereit, Ihnen beim Einstieg zu helfen.

`, text_content: `Willkommen in Ihrem Kundenportal Hallo {{contactName}}, Großartige Neuigkeiten! Sie wurden eingeladen, auf das Kundenportal von {{clientName}} zuzugreifen. Dieses sichere Portal bietet Ihnen sofortigen Zugang zu: ✓ Ihre Support-Tickets anzeigen und verfolgen ✓ Projekt-Updates und Dokumentation einsehen ✓ Direkt mit Ihrem Support-Team kommunizieren MEINEN PORTALZUGANG EINRICHTEN: {{portalLink}} ⏰ ZEITLICH BEGRENZT: Dieser Einladungslink läuft in {{expirationTime}} ab. Bitte schließen Sie die Einrichtung Ihres Kontos vorher ab, um einen unterbrechungsfreien Zugang zu gewährleisten. BENÖTIGEN SIE UNTERSTÜTZUNG? E-Mail: {{clientLocationEmail}} Telefon: {{clientLocationPhone}} Unser Support-Team ist bereit, Ihnen beim Einstieg zu helfen. --- Diese E-Mail wurde an {{contactName}} im Rahmen der Einrichtung Ihres Portalzugangs gesendet. Wenn Sie diese Einladung nicht erwartet haben, kontaktieren Sie uns bitte unter {{clientLocationEmail}}. © {{currentYear}} {{clientName}}. Alle Rechte vorbehalten. `, notification_subtype_id: subtypeIds['portal-invitation'] }, { name: 'tenant-recovery', language_code: 'de', subject: '{{platformName}} - Ihre Anmeldelinks', html_content: `

{{platformName}}

Hallo,

Sie haben Zugang zu Ihrem Kundenportal{{#if isMultiple}} angefordert{{else}} angefordert{{/if}}. {{#if isMultiple}}Wir haben {{tenantCount}} Organisationen gefunden, die mit Ihrer E-Mail-Adresse verknüpft sind.{{else}}Hier ist Ihr Anmeldelink:{{/if}}

{{tenantLinksHtml}}

Sicherheitshinweis: Wenn Sie diese Anmeldelinks nicht angefordert haben, können Sie diese E-Mail sicher ignorieren. Ihr Konto bleibt sicher.

Bei Fragen oder für Unterstützung wenden Sie sich bitte an das Support-Team Ihrer Organisation.

© {{currentYear}} {{platformName}}. Alle Rechte vorbehalten.

Dies ist eine automatisierte Nachricht. Bitte antworten Sie nicht auf diese E-Mail.

`, text_content: `{{platformName}} - Ihre Anmeldelinks Hallo, Sie haben Zugang zu Ihrem Kundenportal{{#if isMultiple}} angefordert{{else}} angefordert{{/if}}. {{#if isMultiple}}Wir haben {{tenantCount}} Organisationen gefunden, die mit Ihrer E-Mail-Adresse verknüpft sind.{{else}}Hier ist Ihr Anmeldelink:{{/if}} Ihre Anmeldelinks: {{tenantLinksText}} Sicherheitshinweis: Wenn Sie diese Anmeldelinks nicht angefordert haben, können Sie diese E-Mail sicher ignorieren. Bei Fragen oder für Unterstützung wenden Sie sich bitte an das Support-Team Ihrer Organisation. --- © {{currentYear}} {{platformName}}. Alle Rechte vorbehalten. Dies ist eine automatisierte Nachricht. Bitte antworten Sie nicht auf diese E-Mail.`, notification_subtype_id: subtypeIds['tenant-recovery'] }, { name: 'no-account-found', language_code: 'de', subject: '{{platformName}} - Zugriffsanfrage', html_content: `

{{platformName}}

Hallo,

Wir haben eine Anfrage für den Zugriff auf das Kundenportal mit dieser E-Mail-Adresse erhalten.

Wenn Sie ein Konto bei uns haben, sollten Sie eine separate E-Mail mit Ihren Anmeldelinks erhalten haben.

Wenn Sie keine Anmelde-E-Mail erhalten haben, könnte dies bedeuten:

Benötigen Sie Hilfe?

Wenn Sie glauben, dass Sie Zugang zu einem Kundenportal haben sollten, wenden Sie sich bitte an das Support-Team Ihres Dienstleisters.

Sicherheitshinweis: Wenn Sie keinen Zugriff angefordert haben, können Sie diese E-Mail sicher ignorieren.

© {{currentYear}} {{platformName}}. Alle Rechte vorbehalten.

Dies ist eine automatisierte Nachricht. Bitte antworten Sie nicht auf diese E-Mail.

`, text_content: `{{platformName}} - Zugriffsanfrage Hallo, Wir haben eine Anfrage für den Zugriff auf das Kundenportal mit dieser E-Mail-Adresse erhalten. Wenn Sie ein Konto bei uns haben, sollten Sie eine separate E-Mail mit Ihren Anmeldelinks erhalten haben. Wenn Sie keine Anmelde-E-Mail erhalten haben, könnte dies bedeuten: - Diese E-Mail-Adresse ist mit keinem Kundenportal-Konto verknüpft - Ihr Konto könnte inaktiv sein - Die E-Mail könnte in Ihrem Spam-Ordner gefiltert worden sein Benötigen Sie Hilfe? Wenn Sie glauben, dass Sie Zugang zu einem Kundenportal haben sollten, wenden Sie sich bitte an das Support-Team Ihres Dienstleisters. Sicherheitshinweis: Wenn Sie keinen Zugriff angefordert haben, können Sie diese E-Mail sicher ignorieren. --- © {{currentYear}} {{platformName}}. Alle Rechte vorbehalten. Dies ist eine automatisierte Nachricht. Bitte antworten Sie nicht auf diese E-Mail.`, notification_subtype_id: subtypeIds['no-account-found'] } ]).onConflict(['name', 'language_code']).ignore(); console.log('✓ German system auth templates added'); // Dutch templates await knex('system_email_templates').insert([ { name: 'email-verification', language_code: 'nl', subject: 'Verifieer uw e-mailadres{{#if registrationClientName}} voor {{registrationClientName}}{{/if}}', html_content: `

E-mailverificatie

Hallo,

Verifieer uw e-mailadres door op onderstaande link te klikken:

E-mail verifiëren

Of kopieer deze link naar uw browser:

{{verificationUrl}}

{{#if expirationTime}}

Deze link verloopt over {{expirationTime}}.

{{/if}}

Als u deze e-mail niet heeft aangevraagd, kunt u deze negeren.

© {{currentYear}} {{tenantClientName}}

`, text_content: `E-mailverificatie Verifieer uw e-mailadres door naar deze link te gaan: {{verificationUrl}} {{#if expirationTime}}Deze link verloopt over {{expirationTime}}.{{/if}} Als u deze e-mail niet heeft aangevraagd, kunt u deze negeren. © {{currentYear}} {{tenantClientName}}`, notification_subtype_id: subtypeIds['email-verification'] }, { name: 'password-reset', language_code: 'nl', subject: 'Verzoek tot wachtwoordherstel', html_content: `

Wachtwoord opnieuw instellen

Hallo {{userName}},

U heeft verzocht om uw wachtwoord voor {{email}} opnieuw in te stellen. Klik op onderstaande link om door te gaan:

Wachtwoord opnieuw instellen

Of kopieer deze link naar uw browser:

{{resetLink}}

Deze link verloopt over {{expirationTime}}.


Als u dit wachtwoordherstel niet heeft aangevraagd, kunt u deze e-mail negeren. Uw wachtwoord blijft ongewijzigd.

{{#if supportEmail}}

Hulp nodig? Neem contact op met {{supportEmail}}

{{/if}}

© {{currentYear}} {{clientName}}

`, text_content: `Verzoek tot wachtwoordherstel Hallo {{userName}}, U heeft verzocht om uw wachtwoord voor {{email}} opnieuw in te stellen. Bezoek de volgende link: {{resetLink}} Deze link verloopt over {{expirationTime}}. Als u dit wachtwoordherstel niet heeft aangevraagd, kunt u deze e-mail negeren. {{#if supportEmail}}Hulp nodig? Neem contact op met {{supportEmail}}{{/if}} © {{currentYear}} {{clientName}}`, notification_subtype_id: subtypeIds['password-reset'] }, { name: 'portal-invitation', language_code: 'nl', subject: 'Uitnodiging voor klantenportaal - {{clientName}}', html_content: ` Portaaltoegang uitnodiging

Welkom bij uw klantenportaal

U bent uitgenodigd om toegang te krijgen tot uw account

Hallo {{contactName}},

Geweldig nieuws! U bent uitgenodigd om toegang te krijgen tot het klantenportaal van {{clientName}}. Dit beveiligde portaal geeft u directe toegang tot:

🎯 Waartoe u toegang heeft

✓ Uw supporttickets bekijken en volgen

✓ Projectupdates en documentatie bekijken

✓ Rechtstreeks communiceren met uw supportteam

Ervaar naadloos servicebeheer met ons intuïtieve portaal. Alles wat u nodig heeft om geïnformeerd en verbonden te blijven, allemaal op één veilige locatie.
Mijn portaaltoegang instellen

Of kopieer en plak deze link in uw browser:

⏰ Tijdgevoelige uitnodiging

Deze uitnodigingslink verloopt over {{expirationTime}}. Voltooi uw accountinstelling voor die tijd om ononderbroken toegang te garanderen.

Hulp nodig?

E-mail: {{clientLocationEmail}}

Telefoon: {{clientLocationPhone}}

Ons supportteam staat klaar om u te helpen aan de slag te gaan.

`, text_content: `Welkom bij uw klantenportaal Hallo {{contactName}}, Geweldig nieuws! U bent uitgenodigd om toegang te krijgen tot het klantenportaal van {{clientName}}. Dit beveiligde portaal geeft u directe toegang tot: ✓ Uw supporttickets bekijken en volgen ✓ Projectupdates en documentatie bekijken ✓ Rechtstreeks communiceren met uw supportteam MIJN PORTAALTOEGANG INSTELLEN: {{portalLink}} ⏰ TIJDGEVOELIG: Deze uitnodigingslink verloopt over {{expirationTime}}. Voltooi uw accountinstelling voor die tijd om ononderbroken toegang te garanderen. HULP NODIG? E-mail: {{clientLocationEmail}} Telefoon: {{clientLocationPhone}} Ons supportteam staat klaar om u te helpen aan de slag te gaan. --- Deze e-mail is verzonden naar {{contactName}} als onderdeel van uw portaaltoegang instelling. Als u deze uitnodiging niet verwachtte, neem dan contact met ons op via {{clientLocationEmail}}. © {{currentYear}} {{clientName}}. Alle rechten voorbehouden. `, notification_subtype_id: subtypeIds['portal-invitation'] }, { name: 'tenant-recovery', language_code: 'nl', subject: '{{platformName}} - Uw inloglinks', html_content: `

{{platformName}}

Hallo,

U heeft toegang aangevraagd tot uw klantenpor{{#if isMultiple}}talen{{else}}taal{{/if}}. {{#if isMultiple}}We hebben {{tenantCount}} organisaties gevonden die gekoppeld zijn aan uw e-mailadres.{{else}}Hier is uw inloglink:{{/if}}

{{tenantLinksHtml}}

Beveiligingsopmerking: Als u deze inloglinks niet heeft aangevraagd, kunt u deze e-mail veilig negeren. Uw account blijft beveiligd.

Als u vragen heeft of hulp nodig heeft, neem dan contact op met het ondersteuningsteam van uw organisatie.

© {{currentYear}} {{platformName}}. Alle rechten voorbehouden.

Dit is een geautomatiseerd bericht. Reageer alstublieft niet op deze e-mail.

`, text_content: `{{platformName}} - Uw inloglinks Hallo, U heeft toegang aangevraagd tot uw klantenpor{{#if isMultiple}}talen{{else}}taal{{/if}}. {{#if isMultiple}}We hebben {{tenantCount}} organisaties gevonden die gekoppeld zijn aan uw e-mailadres.{{else}}Hier is uw inloglink:{{/if}} Uw inloglinks: {{tenantLinksText}} Beveiligingsopmerking: Als u deze inloglinks niet heeft aangevraagd, kunt u deze e-mail veilig negeren. Als u vragen heeft of hulp nodig heeft, neem dan contact op met het ondersteuningsteam van uw organisatie. --- © {{currentYear}} {{platformName}}. Alle rechten voorbehouden. Dit is een geautomatiseerd bericht. Reageer alstublieft niet op deze e-mail.`, notification_subtype_id: subtypeIds['tenant-recovery'] }, { name: 'no-account-found', language_code: 'nl', subject: '{{platformName}} - Toegangsverzoek', html_content: `

{{platformName}}

Hallo,

We hebben een verzoek ontvangen voor toegang tot het klantenportaal met dit e-mailadres.

Als u een account bij ons heeft, zou u een aparte e-mail moeten hebben ontvangen met uw inloglinks.

Als u geen inlog-e-mail heeft ontvangen, kan dit betekenen:

Hulp nodig?

Als u denkt dat u toegang zou moeten hebben tot een klantenportaal, neem dan contact op met het ondersteuningsteam van uw serviceprovider voor hulp.

Beveiligingsopmerking: Als u geen toegang heeft aangevraagd, kunt u deze e-mail veilig negeren.

© {{currentYear}} {{platformName}}. Alle rechten voorbehouden.

Dit is een geautomatiseerd bericht. Reageer alstublieft niet op deze e-mail.

`, text_content: `{{platformName}} - Toegangsverzoek Hallo, We hebben een verzoek ontvangen voor toegang tot het klantenportaal met dit e-mailadres. Als u een account bij ons heeft, zou u een aparte e-mail moeten hebben ontvangen met uw inloglinks. Als u geen inlog-e-mail heeft ontvangen, kan dit betekenen: - Dit e-mailadres is niet gekoppeld aan een klantenportalaccount - Uw account kan inactief zijn - De e-mail kan zijn gefilterd naar uw spam-map Hulp nodig? Als u denkt dat u toegang zou moeten hebben tot een klantenportaal, neem dan contact op met het ondersteuningsteam van uw serviceprovider voor hulp. Beveiligingsopmerking: Als u geen toegang heeft aangevraagd, kunt u deze e-mail veilig negeren. --- © {{currentYear}} {{platformName}}. Alle rechten voorbehouden. Dit is een geautomatiseerd bericht. Reageer alstublieft niet op deze e-mail.`, notification_subtype_id: subtypeIds['no-account-found'] } ]).onConflict(['name', 'language_code']).ignore(); console.log('✓ Dutch system auth templates added'); console.log('System authentication email templates migration complete!'); }; exports.down = async function(knex) { // Remove system auth templates (including tenant-recovery) await knex('system_email_templates') .whereIn('name', ['email-verification', 'password-reset', 'portal-invitation', 'tenant-recovery', 'no-account-found']) .del(); console.log('System authentication email templates removed (including tenant-recovery)'); };