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}}{{ 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}}- {{fluentFormat supportedLocales "click-to-verify"}} + {{getEmailString supportedLocales "click-to-verify"}}
{{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 }}
{{#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 "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"}}