start FxA fixes for new templates

This commit is contained in:
Luke Crouch 2018-12-20 13:27:02 -06:00
Родитель 257d1c1d29
Коммит d16cc5f26f
3 изменённых файлов: 36 добавлений и 32 удалений

Просмотреть файл

@ -6,6 +6,7 @@ const got = require("got");
const AppConstants = require("../app-constants");
const DB = require("../db/DB");
const EmailUtils = require("../email-utils");
const { FluentError } = require("../locale-utils");
@ -53,9 +54,12 @@ async function confirmed(req, res, next, client = FxAOAuthClient) {
const email = JSON.parse(data.body).email;
await DB.addSubscriber(email);
res.render("confirm", {
title: req.fluentFormat("oauth-confirmed-title"),
email: email,
res.render("subpage", {
headline: req.fluentFormat("confirmation-headline"),
subhead: req.fluentFormat("confirmation-blurb"),
title: req.fluentFormat("user-verify-title"),
whichPartial: "subpages/confirm",
emailLinks: EmailUtils.getShareByEmail(req),
});
}

Просмотреть файл

@ -38,34 +38,6 @@ async function add(req, res) {
});
}
function getShareByEmail(req) {
const subject = encodeURIComponent(req.fluentFormat("share-by-email-subject"));
const body = encodeURIComponent(req.fluentFormat("share-by-email-message"));
return {
"gmail" : {
client: "Gmail",
class: "gmail",
href: `https://mail.google.com/mail/?view=cm&fs=1&su=${subject}&body=${body}`,
},
"yahoo" : {
client: "Yahoo",
class: "yahoo",
href: `https://compose.mail.yahoo.com/?subject=${subject}&body=${body}`,
},
"outlook" : {
client: "Outlook",
class: "outlook",
href: `https://outlook.live.com/owa/?path=/mail/action/compose&subject=${subject}&body=${body}`,
},
"default-email" : {
client: req.fluentFormat("share-other"),
class: "default-email-client",
href: `mailto:?subject=${subject}&body=${body}`,
},
};
}
async function verify(req, res) {
if (!req.query.token) {
@ -102,7 +74,7 @@ async function verify(req, res) {
subhead: req.fluentFormat("confirmation-blurb"),
title: req.fluentFormat("user-verify-title"),
whichPartial: "subpages/confirm",
emailLinks: getShareByEmail(req),
emailLinks: EmailUtils.getShareByEmail(req),
});
}

Просмотреть файл

@ -86,6 +86,34 @@ const EmailUtils = {
return `${AppConstants.SERVER_URL}/user/unsubscribe?token=${encodeURIComponent(subscriber.verification_token)}&hash=${encodeURIComponent(subscriber.sha1)}`;
},
getShareByEmail (req) {
const subject = encodeURIComponent(req.fluentFormat("share-by-email-subject"));
const body = encodeURIComponent(req.fluentFormat("share-by-email-message"));
return {
"gmail" : {
client: "Gmail",
class: "gmail",
href: `https://mail.google.com/mail/?view=cm&fs=1&su=${subject}&body=${body}`,
},
"yahoo" : {
client: "Yahoo",
class: "yahoo",
href: `https://compose.mail.yahoo.com/?subject=${subject}&body=${body}`,
},
"outlook" : {
client: "Outlook",
class: "outlook",
href: `https://outlook.live.com/owa/?path=/mail/action/compose&subject=${subject}&body=${body}`,
},
"default-email" : {
client: req.fluentFormat("share-other"),
class: "default-email-client",
href: `mailto:?subject=${subject}&body=${body}`,
},
};
}
};
module.exports = EmailUtils;