Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 2x 2x 2x 2x 2x 15x 12x 12x 12x 12x 12x 12x 12x 12x 12x 2x | // @implements UC-SPACE-008.1
/**
* The sign-up verification email (Cognito Custom Message trigger,
* auth/custom-message.js): in the flow's look when the sign-up started from
* its join page, the Browsway look otherwise, translated either way.
*
* `{####}` is Cognito's placeholder for the code: it must appear in the body.
*/
const { escapeHtml } = require('../email')
const { renderFlowEmailHtml, resolveTheme, readableTextColor } = require('./flowLayout')
const CODE_PLACEHOLDER = '{####}'
const BROWSWAY = { name: 'Browsway Flows' }
const TRANSLATIONS = {
en: {
subject: 'Welcome to Browsway Flows - Verify your email',
flowSubject: 'Join {flow} - Verify your email',
title: 'Welcome aboard!',
flowTitle: 'Join {flow}',
intro:
'Thank you for signing up for Browsway Flows. To complete your registration, please verify your email address using the code below.',
flowIntro:
'To finish creating your account and send your request to join {flow}, verify your email address using the code below.',
code: 'Your verification code:',
expires: 'This code expires in 24 hours.',
ignore:
'If you did not create an account with Browsway Flows, you can safely ignore this email.'
},
fr: {
subject: 'Bienvenue sur Browsway Flows - Vérifiez votre email',
flowSubject: 'Rejoindre {flow} - Vérifiez votre email',
title: 'Bienvenue !',
flowTitle: 'Rejoindre {flow}',
intro:
'Merci de vous être inscrit sur Browsway Flows. Pour terminer votre inscription, vérifiez votre adresse email avec le code ci-dessous.',
flowIntro:
'Pour terminer la création de votre compte et envoyer votre demande pour rejoindre {flow}, vérifiez votre adresse email avec le code ci-dessous.',
code: 'Votre code de vérification :',
expires: 'Ce code expire dans 24 heures.',
ignore: 'Si vous n’avez pas créé de compte sur Browsway Flows, vous pouvez ignorer cet email.'
},
es: {
subject: 'Bienvenido a Browsway Flows - Verifica tu email',
flowSubject: 'Unirte a {flow} - Verifica tu email',
title: '¡Bienvenido!',
flowTitle: 'Unirte a {flow}',
intro:
'Gracias por registrarte en Browsway Flows. Para completar tu registro, verifica tu dirección de email con el código siguiente.',
flowIntro:
'Para terminar de crear tu cuenta y enviar tu solicitud para unirte a {flow}, verifica tu dirección de email con el código siguiente.',
code: 'Tu código de verificación:',
expires: 'Este código caduca en 24 horas.',
ignore: 'Si no has creado una cuenta en Browsway Flows, puedes ignorar este email.'
}
}
const fill = (text, flowName) => text.replace('{flow}', flowName)
/**
* @param {{ lang?: string, flow?: object | null }} params - `flow`: the flow
* whose join page the sign-up started from, null for a plain sign-up
* @returns {{ subject: string, html: string }}
*/
function renderVerificationEmail({ lang, flow }) {
const t = TRANSLATIONS[lang] || TRANSLATIONS.en
const frame = flow || BROWSWAY
const flowName = flow?.name || ''
const theme = resolveTheme(flow?.space?.theme)
const onBackground = readableTextColor(theme.backgroundColor)
const codeBox = `
<p style="color: ${onBackground}; font-size: 14px; margin: 24px 0 8px;">${escapeHtml(t.code)}</p>
<div style="border: 2px dashed ${theme.primaryColor}; border-radius: 8px; padding: 15px 10px; text-align: center;">
<span style="font-family: 'Courier New', monospace; font-size: 28px; font-weight: bold; color: ${onBackground}; letter-spacing: 5px;">${CODE_PLACEHOLDER}</span>
</div>
<p style="color: ${onBackground}; font-size: 12px; margin: 8px 0 0;">${escapeHtml(t.expires)}</p>`
const html = renderFlowEmailHtml({
flow: frame,
title: flow ? fill(t.flowTitle, flowName) : t.title,
paragraphs: [flow ? fill(t.flowIntro, flowName) : t.intro],
highlightHtml: codeBox,
footer: t.ignore
})
const subject = (flow ? fill(t.flowSubject, flowName) : t.subject).replace(/[\r\n]+/g, ' ')
return { subject, html }
}
module.exports = { CODE_PLACEHOLDER, renderVerificationEmail }
|