From eb4933d27ed20897048725092a87c57f5e182ee4 Mon Sep 17 00:00:00 2001 From: Rishabh Garg Date: Thu, 1 Oct 2020 12:31:36 +0530 Subject: [PATCH] Added extra settings to member auth emails (#12238) no issue - Adds accent color, site domain and url to member auth emails for customization --- core/server/services/members/api.js | 14 +++-- core/server/services/members/emails/signin.js | 56 ++++++++++--------- core/server/services/members/emails/signup.js | 55 +++++++++--------- .../services/members/emails/subscribe.js | 53 ++++++++++-------- 4 files changed, 100 insertions(+), 78 deletions(-) diff --git a/core/server/services/members/api.js b/core/server/services/members/api.js index 5cac1ffdb2..9c5d325d8a 100644 --- a/core/server/services/members/api.js +++ b/core/server/services/members/api.js @@ -7,6 +7,8 @@ const signinEmail = require('./emails/signin'); const signupEmail = require('./emails/signup'); const subscribeEmail = require('./emails/subscribe'); const SingleUseTokenProvider = require('./SingleUseTokenProvider'); +const urlUtils = require('../../../shared/url-utils'); + const MAGIC_LINK_TOKEN_VALIDITY = 24 * 60 * 60 * 1000; const ghostMailer = new mail.GhostMailer(); @@ -130,16 +132,20 @@ function createApiInstance(config) { }, getHTML(url, type, email) { const siteTitle = settingsCache.get('title'); + const siteUrl = urlUtils.urlFor('home', true); + const domain = urlUtils.urlFor('home', true).match(new RegExp('^https?://([^/:?#]+)(?:[/:?#]|$)', 'i')); + const siteDomain = (domain && domain[1]); + const accentColor = settingsCache.get('accent_color') || '#15212A'; switch (type) { case 'subscribe': - return subscribeEmail({url, email, siteTitle}); + return subscribeEmail({url, email, siteTitle, accentColor, siteDomain, siteUrl}); case 'signup': - return signupEmail({url, email, siteTitle}); + return signupEmail({url, email, siteTitle, accentColor, siteDomain, siteUrl}); case 'updateEmail': - return subscribeEmail({url, email, siteTitle}); + return subscribeEmail({url, email, siteTitle, accentColor, siteDomain, siteUrl}); case 'signin': default: - return signinEmail({url, email, siteTitle}); + return signinEmail({url, email, siteTitle, accentColor, siteDomain, siteUrl}); } } }, diff --git a/core/server/services/members/emails/signin.js b/core/server/services/members/emails/signin.js index 3a4128d823..e719464f61 100644 --- a/core/server/services/members/emails/signin.js +++ b/core/server/services/members/emails/signin.js @@ -1,4 +1,4 @@ -module.exports = ({siteTitle, email, url}) => ` +module.exports = ({siteTitle, email, url, accentColor = '#15212A', siteDomain, siteUrl}) => ` @@ -49,6 +49,10 @@ module.exports = ({siteTitle, email, url}) => ` max-width: 100% !important; width: auto !important; } + table[class=body] p[class=small], + table[class=body] a[class=small] { + font-size: 11px !important; + } } /* ------------------------------------- PRESERVE THESE STYLES IN THE HEAD @@ -90,22 +94,25 @@ module.exports = ({siteTitle, email, url}) => ` border-bottom-width: 1px; border-bottom-color: #EEF5F8; } + a { + color: #3A464C; + } - - + +
- diff --git a/core/server/services/members/emails/signup.js b/core/server/services/members/emails/signup.js index 512c446c09..b22a157ae6 100644 --- a/core/server/services/members/emails/signup.js +++ b/core/server/services/members/emails/signup.js @@ -1,4 +1,4 @@ -module.exports = ({siteTitle, email, url}) => ` +module.exports = ({siteTitle, email, url, accentColor = '#15212A', siteDomain, siteUrl}) => ` @@ -49,6 +49,10 @@ module.exports = ({siteTitle, email, url}) => ` max-width: 100% !important; width: auto !important; } + table[class=body] p[class=small], + table[class=body] a[class=small] { + font-size: 11px !important; + } } /* ------------------------------------- PRESERVE THESE STYLES IN THE HEAD @@ -90,13 +94,16 @@ module.exports = ({siteTitle, email, url}) => ` border-bottom-width: 1px; border-bottom-color: #EEF5F8; } + a { + color: #3A464C; + } - -
  +
- + - @@ -140,24 +162,8 @@ module.exports = ({siteTitle, email, url}) => `
+ + + + + + + + + + + +
@@ -118,7 +125,7 @@ module.exports = ({siteTitle, email, url}) => ` - +
Sign in to ${siteTitle} Sign in to ${siteTitle}
@@ -130,9 +137,24 @@ module.exports = ({siteTitle, email, url}) => `

See you soon!
The team at ${siteTitle}


You can also copy & paste this URL into your browser:

-

${url}

+

${url}

+

If you did not make this request, you can safely ignore this email.

+
+

This message was sent from ${siteDomain} to ${email}

+
- - - - +
 
+ +
- - + + + + + + + + + + +
  +
@@ -105,7 +112,7 @@ module.exports = ({siteTitle, email, url}) => `
+
@@ -118,7 +125,7 @@ module.exports = ({siteTitle, email, url}) => ` - +
Activate my account Activate my account
@@ -129,34 +136,32 @@ module.exports = ({siteTitle, email, url}) => `

For your security, the link will expire in 24 hours time.

See you soon!
The team at ${siteTitle}


-

You can also copy & paste this URL into your browser:

-

${url}

+

You can also copy & paste this URL into your browser:

+

${url}

+

If you did not make this request, you can simply delete this message. You will not be signed up, and no account will be created for you.

+
+

This message was sent from ${siteDomain} to ${email}

+
- - - - diff --git a/core/server/services/members/emails/subscribe.js b/core/server/services/members/emails/subscribe.js index dab9f51c3e..bf5e782a92 100644 --- a/core/server/services/members/emails/subscribe.js +++ b/core/server/services/members/emails/subscribe.js @@ -1,4 +1,4 @@ -module.exports = ({siteTitle, email, url}) => ` +module.exports = ({siteTitle, email, url, accentColor = '#15212A', siteDomain, siteUrl}) => ` @@ -49,6 +49,10 @@ module.exports = ({siteTitle, email, url}) => ` max-width: 100% !important; width: auto !important; } + table[class=body] p[class=small], + table[class=body] a[class=small] { + font-size: 11px !important; + } } /* ------------------------------------- PRESERVE THESE STYLES IN THE HEAD @@ -90,13 +94,16 @@ module.exports = ({siteTitle, email, url}) => ` border-bottom-width: 1px; border-bottom-color: #EEF5F8; } + a { + color: #3A464C; + } - - + +
- - + + + + + + + + + + +
  +
@@ -105,7 +112,7 @@ module.exports = ({siteTitle, email, url}) => `
+
@@ -118,7 +125,7 @@ module.exports = ({siteTitle, email, url}) => ` - +
Confirm email address Confirm email address
@@ -130,33 +137,31 @@ module.exports = ({siteTitle, email, url}) => `

All the best!
The team at ${siteTitle}


You can also copy & paste this URL into your browser:

-

${url}

+

${url}

+

If you did not make this request, you can simply delete this message.
You will not be subscribed.

+
+

This message was sent from ${siteDomain} to ${email}

+
- - - -