diff --git a/controllers/oauth.js b/controllers/oauth.js index 11f92d3dc90..bf25c43abf7 100644 --- a/controllers/oauth.js +++ b/controllers/oauth.js @@ -9,7 +9,6 @@ const AppConstants = require("../app-constants"); const DB = require("../db/DB"); const EmailUtils = require("../email-utils"); const { FluentError } = require("../locale-utils"); -const HBSHelpers = require("../template-helpers/hbs-helpers"); const HIBP = require("../hibp"); const mozlog = require("../log"); const sha1 = require("../sha1-utils"); @@ -94,7 +93,7 @@ async function confirmed(req, res, next, client = FxAOAuthClient) { const utmID = "report"; - /* TODO: restore this when email templates are fixed + await EmailUtils.sendEmail( email, req.fluentFormat("user-verify-email-report-subject"), @@ -102,7 +101,7 @@ async function confirmed(req, res, next, client = FxAOAuthClient) { { supportedLocales: req.supportedLocales, email: email, - date: HBSHelpers.prettyDate(req.supportedLocales, new Date()), + date: req.fluentFormat(new Date()), unsafeBreachesForEmail: unsafeBreachesForEmail, scanAnotherEmailHref: EmailUtils.getScanAnotherEmailUrl(utmID), unsubscribeUrl: EmailUtils.getUnsubscribeUrl(verifiedSubscriber, utmID), @@ -110,11 +109,9 @@ async function confirmed(req, res, next, client = FxAOAuthClient) { whichView: "email_partials/report", } ); - */ req.session.user = verifiedSubscriber; } - - res.redirect("/scan/user_dashboard"); + res.redirect("/user/dashboard"); } module.exports = { diff --git a/email-utils.js b/email-utils.js index a10a9e2edc1..a1a47b3741a 100644 --- a/email-utils.js +++ b/email-utils.js @@ -6,7 +6,7 @@ const AppConstants = require("./app-constants"); const nodemailer = require("nodemailer"); const hbs = require("nodemailer-express-handlebars"); -const HBSHelpers = require("./template-helpers/hbs-helpers"); +const HBSHelpers = require("./template-helpers/"); const mozlog = require("./log"); @@ -18,7 +18,7 @@ const hbsOptions = { layoutsDir: __dirname + "/views/layouts", defaultLayout: "default_email", partialsDir: __dirname + "/views/partials", - helpers: HBSHelpers, + helpers: HBSHelpers.helpers, }, viewPath: __dirname + "/views/layouts", extName: ".hbs", diff --git a/template-helpers/emails.js b/template-helpers/emails.js new file mode 100644 index 00000000000..8768acea95f --- /dev/null +++ b/template-helpers/emails.js @@ -0,0 +1,25 @@ +"use strict"; + +const e_localeString = (locales, string) => { + console.log(`localeString ${string}`); +}; + +const e_localizedBreachDataClasses = (locales, string) => { + console.log(`localizedBreachDataClasses ${string}`); +}; + +const e_prettyDate = (locales, string) => { + console.log(`prettyDate ${string}`); +}; + + +const getEmailString = (locales, stringId) => { + console.log(stringId); +}; + +module.exports = { + e_localeString, + e_localizedBreachDataClasses, + e_prettyDate, + getEmailString, +}; diff --git a/template-helpers/index.js b/template-helpers/index.js index 414aee4ef04..266adfbbb08 100644 --- a/template-helpers/index.js +++ b/template-helpers/index.js @@ -2,6 +2,7 @@ const articles = require("./articles"); const breaches = require("./breaches"); +const emails = require("./emails"); const footer = require("./footer"); const header = require("./header"); const legacyHelpers = require("./hbs-helpers"); @@ -13,6 +14,7 @@ module.exports = { helpers: Object.assign( articles, breaches, + emails, footer, header, legacyHelpers, diff --git a/views/partials/email_partials/breach_alert.hbs b/views/partials/email_partials/breach_alert.hbs index 695c7d698dd..1d161411278 100644 --- a/views/partials/email_partials/breach_alert.hbs +++ b/views/partials/email_partials/breach_alert.hbs @@ -4,10 +4,10 @@

{{ breachAlert.Title }}

-

{{fluentFormat supportedLocales "breach-date"}}{{prettyDate supportedLocales breachAlert.BreachDate }}

-

{{fluentFormat supportedLocales "compromised-accounts"}}{{localeString supportedLocales breachAlert.PwnCount }}

+

{{getEmailString supportedLocales "breach-date"}}{{e_prettyDate supportedLocales breachAlert.BreachDate }}

+

{{getEmailString supportedLocales "compromised-accounts"}}{{e_localeString supportedLocales breachAlert.PwnCount }}

{{#if breachAlert.DataClasses }} -

{{fluentFormat supportedLocales "compromised-data"}}{{localizedBreachDataClasses supportedLocales breachAlert.DataClasses }}

+

{{getEmailString supportedLocales "compromised-data"}}{{e_localizedBreachDataClasses supportedLocales breachAlert.DataClasses }}

{{/if}} diff --git a/views/partials/email_partials/email_button.hbs b/views/partials/email_partials/email_button.hbs index 4cfc767cd83..1b8193aef13 100644 --- a/views/partials/email_partials/email_button.hbs +++ b/views/partials/email_partials/email_button.hbs @@ -6,7 +6,7 @@ - {{fluentFormat supportedLocales fluentStringID}} + {{getEmailString supportedLocales fluentStringID}} diff --git a/views/partials/email_partials/email_footer.hbs b/views/partials/email_partials/email_footer.hbs index 86b1c791aed..2a1e8b4fe2d 100644 --- a/views/partials/email_partials/email_footer.hbs +++ b/views/partials/email_partials/email_footer.hbs @@ -2,14 +2,14 @@ @@ -26,7 +26,7 @@ diff --git a/views/partials/email_partials/email_hibp_attribution.hbs b/views/partials/email_partials/email_hibp_attribution.hbs index 92988bb9eff..67c179e7c82 100644 --- a/views/partials/email_partials/email_hibp_attribution.hbs +++ b/views/partials/email_partials/email_hibp_attribution.hbs @@ -1,6 +1,6 @@ - {{{fluentFormat supportedLocales "hibp-attribution" hibp-link='Have I Been Pwned'}}} + {{{getEmailString supportedLocales "hibp-attribution" hibp-link='Have I Been Pwned'}}} diff --git a/views/partials/email_partials/email_single_breach.hbs b/views/partials/email_partials/email_single_breach.hbs index 9b07bb608ab..c63f954acee 100644 --- a/views/partials/email_partials/email_single_breach.hbs +++ b/views/partials/email_partials/email_single_breach.hbs @@ -4,10 +4,10 @@

{{ this.Title }}

-

{{fluentFormat supportedLocales "breach-date"}}{{prettyDate supportedLocales this.BreachDate }}

-

{{fluentFormat supportedLocales "compromised-accounts"}}{{localeString supportedLocales this.PwnCount }}

+

{{getString supportedLocales "breach-date"}}{{prettyDate supportedLocales this.BreachDate }}

+

{{getString supportedLocales "compromised-accounts"}}{{localeString supportedLocales this.PwnCount }}

{{#if this.DataClasses }} -

{{fluentFormat supportedLocales "compromised-data"}}{{localizedBreachDataClasses supportedLocales this.DataClasses }}

+

{{getString supportedLocales "compromised-data"}}{{localizedBreachDataClasses supportedLocales this.DataClasses }}

{{/if}} diff --git a/views/partials/email_partials/email_verify.hbs b/views/partials/email_partials/email_verify.hbs index 52d821fa606..fb641ced371 100644 --- a/views/partials/email_partials/email_verify.hbs +++ b/views/partials/email_partials/email_verify.hbs @@ -4,7 +4,7 @@

- {{fluentFormat supportedLocales "click-to-verify"}} + {{getEmailString supportedLocales "click-to-verify"}}

diff --git a/views/partials/email_partials/report_header_details.hbs b/views/partials/email_partials/report_header_details.hbs index 0c9e8bb69e1..16b0eb4a1b3 100644 --- a/views/partials/email_partials/report_header_details.hbs +++ b/views/partials/email_partials/report_header_details.hbs @@ -1,6 +1,6 @@
-

{{fluentFormat supportedLocales "firefox-monitor-report"}}

-

{{fluentFormat supportedLocales "report-date"}} {{ date }}

-

{{fluentFormat supportedLocales "email-address"}} {{ email }}

+

{{getEmailString supportedLocales "firefox-monitor-report"}}

+

{{getEmailString supportedLocales "report-date"}} {{ date }}

+

{{getEmailString supportedLocales "email-address"}} {{ email }}

diff --git a/views/partials/email_partials/report_list_headline.hbs b/views/partials/email_partials/report_list_headline.hbs index 0df581f2abf..fef900c5d65 100644 --- a/views/partials/email_partials/report_list_headline.hbs +++ b/views/partials/email_partials/report_list_headline.hbs @@ -1,26 +1,26 @@

{{#if breachAlert}} - {{fluentFormat supportedLocales "breach-alert-headline"}} + {{getEmailString supportedLocales "breach-alert-headline"}} {{else}} - {{fluentFormat supportedLocales "report-headline" breachCount=unsafeBreachesForEmail.length}} + {{getEmailString supportedLocales "report-headline" breachCount=unsafeBreachesForEmail.length}} {{/if}}

{{#if breachAlert}} - {{fluentFormat supportedLocales "breach-alert-subhead"}} + {{getEmailString supportedLocales "breach-alert-subhead"}} {{else}} {{#ifCompare unsafeBreachesForEmail.length "===" 0}} - {{fluentFormat supportedLocales "report-subhead-no-breaches"}} + {{getEmailString supportedLocales "report-subhead-no-breaches"}} {{else}} - {{fluentFormat supportedLocales "report-subhead-found-breaches" breachCount=unsafeBreachesForEmail.length}} + {{getEmailString supportedLocales "report-subhead-found-breaches" breachCount=unsafeBreachesForEmail.length}} {{/ifCompare}}

{{#ifCompare unsafeBreachesForEmail.length "===" 0}}

- {{fluentFormat supportedLocales "pwt-section-headline"}} + {{getEmailString supportedLocales "pwt-section-headline"}}

-

{{fluentFormat supportedLocales "report-pwt-blurb"}}

+

{{getEmailString supportedLocales "report-pwt-blurb"}}

{{/ifCompare}} {{/if}} diff --git a/views/partials/email_partials/report_what_to_do_next.hbs b/views/partials/email_partials/report_what_to_do_next.hbs index 8022a17e5a4..ea3578ea6a7 100644 --- a/views/partials/email_partials/report_what_to_do_next.hbs +++ b/views/partials/email_partials/report_what_to_do_next.hbs @@ -1,7 +1,7 @@

- {{fluentFormat supportedLocales "what-to-do-next"}} + {{getEmailString supportedLocales "what-to-do-next"}}