From 8c336a97d7431056c2369c22ddf22ad6f9afd19c Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 11 Sep 2019 12:27:56 +0100 Subject: [PATCH 01/21] install mustache --- backend/package.json | 7 ++++--- backend/yarn.lock | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index dd75b54d9..fecfe3441 100644 --- a/backend/package.json +++ b/backend/package.json @@ -89,6 +89,7 @@ "metascraper-video": "^5.6.5", "metascraper-youtube": "^5.6.7", "minimatch": "^3.0.4", + "mustache": "^3.0.3", "neo4j-driver": "~1.7.6", "neo4j-graphql-js": "^2.7.2", "neode": "^0.3.3", @@ -100,8 +101,8 @@ "slug": "~1.1.0", "trunc-html": "~1.1.2", "uuid": "~3.3.3", - "xregexp": "^4.2.4", - "wait-on": "~3.3.0" + "wait-on": "~3.3.0", + "xregexp": "^4.2.4" }, "devDependencies": { "@babel/cli": "~7.6.0", @@ -131,4 +132,4 @@ "prettier": "~1.18.2", "supertest": "~4.0.2" } -} \ No newline at end of file +} diff --git a/backend/yarn.lock b/backend/yarn.lock index b1a1e0368..d59891c1c 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -6104,6 +6104,11 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +mustache@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/mustache/-/mustache-3.0.3.tgz#ee4fb971887fa6cc1b6b6d219a74b5e3c7535f32" + integrity sha512-vM5FkMHamTYmVYeAujypihuPrJQDtaUIlKeeVb1AMJ73OZLtWiF7GprqrjxD0gJWT53W9JfqXxf97nXQjMQkqA== + mute-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" From f802eab27df5a5ee7b6a34f088c40c7b292043d6 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 11 Sep 2019 12:44:15 +0100 Subject: [PATCH 02/21] copy email text to separate file --- .../src/middleware/email/templates/signup.js | 52 +++---------------- .../src/middleware/email/templates/signup.txt | 42 +++++++++++++++ 2 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 backend/src/middleware/email/templates/signup.txt diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index 54cc51be2..25f3681d7 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -1,4 +1,9 @@ import CONFIG from '../../../config' +import fs from 'fs' +import path from 'path' +import mustache from 'mustache' + +const signupText = fs.readFileSync(path.join(__dirname, './signup.txt'), 'utf-8') export const signupTemplate = options => { const { @@ -11,52 +16,11 @@ export const signupTemplate = options => { actionUrl.searchParams.set('nonce', nonce) actionUrl.searchParams.set('email', email) + console.log(actionUrl) + return { to: email, subject, - text: ` -Willkommen bei Human Connection! Klick auf diesen Link, um den -Registrierungsprozess abzuschließen und um ein Benutzerkonto zu erstellen! - -${actionUrl} - -Alternativ kannst du diesen Code auch kopieren und im Browserfenster einfügen: - -${nonce} - -Bitte ignoriere diese Mail, falls du dich nicht bei Human Connection angemeldet -hast. Bei Fragen kontaktiere gerne unseren Support: - -${supportUrl} - -Danke, -Das Human Connection Team - - -English Version -=============== - -Welcome to Human Connection! Use this link to complete the registration process -and create a user account: - -${actionUrl} - -You can also copy+paste this verification nonce in your browser window: - -${nonce} - -If you did not signed up for Human Connection, please ignore this email or -contact support if you have questions: - -${supportUrl} - -Thanks, -The Human Connection Team - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland - `, + text: mustache.render(signupText, { actionUrl, nonce, supportUrl }) } } diff --git a/backend/src/middleware/email/templates/signup.txt b/backend/src/middleware/email/templates/signup.txt new file mode 100644 index 000000000..c3e2ba8c6 --- /dev/null +++ b/backend/src/middleware/email/templates/signup.txt @@ -0,0 +1,42 @@ +Willkommen bei Human Connection! Klick auf diesen Link, um den +Registrierungsprozess abzuschließen und um ein Benutzerkonto zu erstellen! + +{{{actionUrl}}} + +Alternativ kannst du diesen Code auch kopieren und im Browserfenster einfügen: + +{{{nonce}}} + +Bitte ignoriere diese Mail, falls du dich nicht bei Human Connection angemeldet +hast. Bei Fragen kontaktiere gerne unseren Support: + +{{{supportUrl}}} + +Danke, +Das Human Connection Team + + +English Version +=============== + +Welcome to Human Connection! Use this link to complete the registration process +and create a user account: + +{{{actionUrl}}} + +You can also copy+paste this verification nonce in your browser window: + +{{{nonce}}} + +If you did not signed up for Human Connection, please ignore this email or +contact support if you have questions: + +{{{supportUrl}}} + +Thanks, +The Human Connection Team + +Human Connection gemeinnützige GmbH +Bahnhofstr. 11 +73235 Weilheim / Teck +Deutschland From 1cd354ff17dceab55808d23e9101d23bda7b7f66 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 11 Sep 2019 12:51:27 +0100 Subject: [PATCH 03/21] paste html template from TedGoas/Cerberus --- .../middleware/email/templates/signup.html | 434 ++++++++++++++++++ .../src/middleware/email/templates/signup.js | 4 +- 2 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 backend/src/middleware/email/templates/signup.html diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html new file mode 100644 index 000000000..7316dc841 --- /dev/null +++ b/backend/src/middleware/email/templates/signup.html @@ -0,0 +1,434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ (Optional) This text will appear in the inbox preview, but not the email body. It can be used to supplement the + email subject line or even summarize the email's contents. Extended text preheaders (~490 characters) seems like a + better UX for anyone using a screenreader or voice-command apps like Siri to dictate the contents of an email. If + this text is not included, email clients will automatically populate it using the text (including image alt text) + at the start of the email's body. +
+ + + + +
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index 25f3681d7..a83e59d5b 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -4,6 +4,7 @@ import path from 'path' import mustache from 'mustache' const signupText = fs.readFileSync(path.join(__dirname, './signup.txt'), 'utf-8') +const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8') export const signupTemplate = options => { const { @@ -21,6 +22,7 @@ export const signupTemplate = options => { return { to: email, subject, - text: mustache.render(signupText, { actionUrl, nonce, supportUrl }) + text: mustache.render(signupText, { actionUrl, nonce, supportUrl }), + html: mustache.render(signupHtml, {}), } } From 58b56754a42af68559524243e718675ac4173a34 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 11 Sep 2019 12:51:52 +0100 Subject: [PATCH 04/21] remove console log --- backend/src/middleware/email/templates/signup.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index a83e59d5b..7cceb0c70 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -17,8 +17,6 @@ export const signupTemplate = options => { actionUrl.searchParams.set('nonce', nonce) actionUrl.searchParams.set('email', email) - console.log(actionUrl) - return { to: email, subject, From 61ce27464c68836ba6e73638889694c5e3e88dbf Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Mon, 16 Sep 2019 17:02:59 +0100 Subject: [PATCH 05/21] adapt template to follow human connection styleguide (wip) --- .../middleware/email/templates/signup.html | 201 +++++------------- 1 file changed, 59 insertions(+), 142 deletions(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 7316dc841..3a3f2760d 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -9,7 +9,7 @@ - + Welcome to Human Connection @@ -18,14 +18,14 @@ - + @@ -174,39 +174,20 @@ - -
+ +
- -
- (Optional) This text will appear in the inbox preview, but not the email body. It can be used to supplement the - email subject line or even summarize the email's contents. Extended text preheaders (~490 characters) seems like a - better UX for anyone using a screenreader or voice-command apps like Siri to dictate the contents of an email. If - this text is not included, email clients will automatically populate it using the text (including image alt text) - at the start of the email's body. -
- - - - -
- ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  -
- - - alt_text @@ -234,8 +213,10 @@ - alt_text @@ -246,14 +227,14 @@ - @@ -262,10 +243,10 @@
+

- Praesent laoreet malesuada cursus.

-

Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent - taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent laoreet - malesuada cursus. Maecenas scelerisque congue eros eu posuere. Praesent in felis ut velit pretium - lobortis rhoncus ut erat.

+ style="margin: 0 0 10px 0; font-family: Lato, sans-serif; font-size: 25px; line-height: 30px; color: #333333; font-weight: normal;"> + Welcome to Human Connection! +

Thank you for joining our cause – it's awesome to have you on board. There's + just one tiny step missing before we can start shaping the world together: Please confirm your + e-mail address by clicking the button below!

-
+ Primary - Button + style="background: #17b53e; font-family: Lato, sans-serif; font-size: 15px; line-height: 15px; text-decoration: none; padding: 13px 17px; color: #ffffff; display: block; border-radius: 4px;">Confirm + your email address
@@ -273,20 +254,9 @@ - -

- Praesent in felis ut velit pretium lobortis rhoncus ut erat.

-
    -
  • A list item.
  • -
  • Another list item here.
  • -
  • Everyone gets a list item, list items for - everyone!
  • -
-

Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent - taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent laoreet - malesuada cursus. Maecenas scelerisque congue eros eu posuere. Praesent in felis ut velit pretium - lobortis rhoncus ut erat.

+ +

Or you can copy this code and paste it in your browser window:

@@ -294,52 +264,9 @@ - - - - - - - - -
- - - - - - - -
- alt_text -
-

Maecenas sed ante pellentesque, posuere leo id, eleifend dolor.

-
-
- - - - - - - -
- alt_text -
-

Maecenas sed ante pellentesque, posuere leo id, eleifend dolor.

-
-
- - - - - +   @@ -350,11 +277,37 @@ - + +
-

Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent - taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent laoreet - malesuada cursus. Maecenas scelerisque congue eros eu posuere. Praesent in felis ut velit pretium - lobortis rhoncus ut erat.

+
+

If you didn't sign up for Human Connection we recommend you to check it out! + It's an online platform for people to connect and change the world together.

+

PS: If you ignore this email we will not create an account for + you. ;)

+
+ + + + + + + +   + + + + + + + + + +
+

Feel free to contact our support team with any questions you might have.

+

Thank you, and see you soon on Human Connection!

+

– The Human Connection Team

@@ -370,14 +323,11 @@ style="margin: auto;"> - View as a Web Page - + style="padding: 20px; font-family: Lato, sans-serif; font-size: 12px; line-height: 15px; text-align: center; color: #888888;">

- Company Name
123 Fake Street, SpringField, OR, 97477 - US
(123) 456-7890
+ Human Connection gGmbH
Bahnhofstraße 11
73235 Weilheim / + Teck
Germany


- unsubscribe @@ -390,39 +340,6 @@ - - - - - -
- -
- - - - - -   - - - - + + +
-

If you didn't sign up for Human Connection we recommend you to check it out! + style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;"> +

If you didn't sign up for Human Connection we recommend you to check it out! It's an online platform for people to connect and change the world together.

PS: If you ignore this email we will not create an account for you. ;)

–––––––––––––––––––––––––––––––––––––––––––––––
- - - -   - - - - @@ -325,7 +320,7 @@ From c94715a1284c790b26d3c1fe2e59ce943c6fae23 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Mon, 16 Sep 2019 18:29:43 +0100 Subject: [PATCH 07/21] pass options to html template --- .../src/middleware/email/templates/signup.html | 15 +++++++++++++++ backend/src/middleware/email/templates/signup.js | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index a04fa0e87..189e5f186 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -188,6 +188,21 @@ - +
-

Feel free to contact our support team with any questions you might have.

-

Thank you, and see you soon on Human Connection!

+ style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;"> +

Feel free to contact our + support team with any + questions you might have.

+

See you soon on Human Connection!

– The Human Connection Team



- Human Connection gGmbH
Bahnhofstraße 11
73235 Weilheim / + Human Connection gGmbH
Bahnhofstraße 11, 73235 Weilheim / Teck
Germany


+ +
+ Here is your signup link. +
+ + + + +
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
- ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  + ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ 
@@ -271,12 +275,15 @@
+

Or you can copy this code and paste it in your browser window: {{{ nonce }}}

––––––––––––––––––––––––––––––––––––––––––––––– +

–––––––––––––––––––––––––––––––––––––––––––––––

+
@@ -292,13 +299,15 @@ style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">

If you didn't sign up for Human Connection we recommend you to check it out! - It's an online platform for people to connect and change the world together.

+ It's a social network from people for people who want to connect and change the world together.

PS: If you ignore this email we will not create an account for you. ;)

- ––––––––––––––––––––––––––––––––––––––––––––––– + +

–––––––––––––––––––––––––––––––––––––––––––––––

+ @@ -314,7 +323,7 @@ style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">

Feel free to contact our support team with any - questions you might have.

+ questions you have.

See you soon on Human Connection!

– The Human Connection Team

diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index 2f77d0efa..a6abdf6f2 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -3,7 +3,6 @@ import fs from 'fs' import path from 'path' import mustache from 'mustache' -const signupText = fs.readFileSync(path.join(__dirname, './signup.txt'), 'utf-8') const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8') export const signupTemplate = options => { @@ -20,7 +19,6 @@ export const signupTemplate = options => { return { to: email, subject, - text: mustache.render(signupText, { actionUrl, nonce, supportUrl }), html: mustache.render(signupHtml, { actionUrl, nonce, supportUrl }), } } diff --git a/backend/src/middleware/email/templates/signup.txt b/backend/src/middleware/email/templates/signup.txt deleted file mode 100644 index c3e2ba8c6..000000000 --- a/backend/src/middleware/email/templates/signup.txt +++ /dev/null @@ -1,42 +0,0 @@ -Willkommen bei Human Connection! Klick auf diesen Link, um den -Registrierungsprozess abzuschließen und um ein Benutzerkonto zu erstellen! - -{{{actionUrl}}} - -Alternativ kannst du diesen Code auch kopieren und im Browserfenster einfügen: - -{{{nonce}}} - -Bitte ignoriere diese Mail, falls du dich nicht bei Human Connection angemeldet -hast. Bei Fragen kontaktiere gerne unseren Support: - -{{{supportUrl}}} - -Danke, -Das Human Connection Team - - -English Version -=============== - -Welcome to Human Connection! Use this link to complete the registration process -and create a user account: - -{{{actionUrl}}} - -You can also copy+paste this verification nonce in your browser window: - -{{{nonce}}} - -If you did not signed up for Human Connection, please ignore this email or -contact support if you have questions: - -{{{supportUrl}}} - -Thanks, -The Human Connection Team - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland diff --git a/backend/yarn.lock b/backend/yarn.lock index d59891c1c..73b67e5ef 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -4293,6 +4293,11 @@ he@0.5.0: resolved "https://registry.yarnpkg.com/he/-/he-0.5.0.tgz#2c05ffaef90b68e860f3fd2b54ef580989277ee2" integrity sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI= +he@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + helmet-crossdomain@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/helmet-crossdomain/-/helmet-crossdomain-0.4.0.tgz#5f1fe5a836d0325f1da0a78eaa5fd8429078894e" @@ -4365,7 +4370,17 @@ html-encoding-sniffer@^1.0.2: dependencies: whatwg-encoding "^1.0.1" -htmlparser2@^3.10.0, htmlparser2@^3.9.1: +html-to-text@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/html-to-text/-/html-to-text-5.1.1.tgz#2d89db7bf34bc7bcb7d546b1b228991a16926e87" + integrity sha512-Bci6bD/JIfZSvG4s0gW/9mMKwBRoe/1RWLxUME/d6WUSZCdY7T60bssf/jFf7EYXRyqU4P5xdClVqiYU0/ypdA== + dependencies: + he "^1.2.0" + htmlparser2 "^3.10.1" + lodash "^4.17.11" + minimist "^1.2.0" + +htmlparser2@^3.10.0, htmlparser2@^3.10.1, htmlparser2@^3.9.1: version "3.10.1" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f" integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ== @@ -6299,6 +6314,13 @@ node-releases@^1.1.25: dependencies: semver "^5.3.0" +nodemailer-html-to-text@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/nodemailer-html-to-text/-/nodemailer-html-to-text-3.1.0.tgz#11e4e435eb03e4f3b439aaf294b1bd1377e7f789" + integrity sha512-AijyAZgcFb6b53g1oMwdCKyLYQVJzbgZKbs3Bma8zR5hPR1gkajQKGGZbwtuA5JhUqnyC8pjp+tiaS7CkQ8TRg== + dependencies: + html-to-text "^5.1.1" + nodemailer@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.3.0.tgz#a89b0c62d3937bdcdeecbf55687bd7911b627e12" From 24fb601739c9c527ae999cc4c74608678c325322 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Tue, 17 Sep 2019 15:17:36 +0100 Subject: [PATCH 09/21] clean up email template --- .../middleware/email/templates/signup.html | 107 +++++------------- 1 file changed, 27 insertions(+), 80 deletions(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index fd286a553..9acdd8887 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -3,37 +3,27 @@ xmlns:o="urn:schemas-microsoft-com:office:office"> - - - - + + + + - - Welcome to Human Connection + Welcome to Human Connection - - - - + + - - + - - - + - - - - + - - -
- +
Here is your signup link.
- - - -
‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ 
- -
From e53609ab14bc5b3a0d76978456038eb2614f6e7c Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Tue, 17 Sep 2019 15:28:24 +0100 Subject: [PATCH 10/21] add german translation to signup template --- .../middleware/email/templates/signup.html | 119 +++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 9acdd8887..a538f71d1 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -169,6 +169,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Human Connection community logo +
+ + + + + + + + + + + + + +
+

English version below!

+

+ Willkommen bei Human Connection!

+

Danke, dass du dich angemeldet hast – wir freuen uns, dich dabei zu haben. Jetzt + fehlt nur noch eine Kleinigkeit, bevor wir gemeinsam die Welt verbessern können... Bitte bestätige + deine E-Mail Adresse:

+
+ + + + + +
+ Bestätige + deine E-Mail Adresse +
+ +
+

+

Oder du kopierst diesen Code in dein Browserfenster: {{{ nonce }}}

+
+

–––––––––––––––––––––––––––––––––––––––––––––––

+
+
+ + + + + + + +
+

Falls du dich nicht selbst bei Human Connection angemeldet hast, schau doch mal vorbei! + Wir sind ein gemeinnütziges Aktionsnetzwerk – von Menschen für Menschen.

+

PS: Wenn du keinen Account bei uns möchtest, kannst du diese + E-Mail einfach ignorieren. ;)

+
+

–––––––––––––––––––––––––––––––––––––––––––––––

+
+
+ + + + +
+

Melde dich gerne bei + unserem Support Team wenn du Fragen hast.

+

Bis bald bei Human Connection!

+

– Dein Human Connection Team

+
+
+ + + @@ -282,7 +399,7 @@
- + Date: Wed, 18 Sep 2019 14:39:03 +0100 Subject: [PATCH 11/21] add language toggle --- .../middleware/email/templates/signup.html | 75 +++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index a538f71d1..67317e7f4 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -142,6 +142,59 @@ } } + + + @@ -169,9 +222,17 @@ @@ -286,8 +351,8 @@ -
+ + + + + +

+ - +
@@ -196,7 +257,6 @@ + + +
+
From 5b8d2eb2f6a6c9ee2101c2eb54f276ced08824f4 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 18 Sep 2019 14:49:39 +0100 Subject: [PATCH 12/21] fix lint errors --- backend/src/middleware/email/emailMiddleware.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/middleware/email/emailMiddleware.js b/backend/src/middleware/email/emailMiddleware.js index 8ce6973e0..1a63b2c10 100644 --- a/backend/src/middleware/email/emailMiddleware.js +++ b/backend/src/middleware/email/emailMiddleware.js @@ -8,17 +8,20 @@ let sendMail if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) { sendMail = async templateArgs => { const transport = transporter() - transport.use('compile', htmlToText({ - ignoreImage: true, - wordwrap: false, - })) + transport.use( + 'compile', + htmlToText({ + ignoreImage: true, + wordwrap: false, + }), + ) await transport.sendMail({ from: '"Human Connection" ', ...templateArgs, }) } } else { - sendMail = () => { } + sendMail = () => {} if (process.env.NODE_ENV !== 'test') { // eslint-disable-next-line no-console console.log('Warning: Email middleware will not try to send mails.') From 96ced538437b9051caa703f09265b4f11bceec83 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 18 Sep 2019 15:16:53 +0100 Subject: [PATCH 13/21] fix hover effect for language toggle --- backend/src/middleware/email/templates/signup.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 67317e7f4..0837b0641 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -154,9 +154,10 @@ font-family: Lato, sans-serif; font-size: 16px; border: 1px solid gainsboro; + cursor: pointer; } - .toggle:hover+label { + .toggle+label:hover { background-color: #bee876; } From ec0cf36256c7d598c019ac2964b11439a8740e9e Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Wed, 18 Sep 2019 18:00:34 +0100 Subject: [PATCH 14/21] refactor email middleware --- .../src/middleware/email/emailMiddleware.js | 66 +++++++++---------- .../email/templates/passwordReset.js | 2 + .../src/middleware/email/templates/signup.js | 16 ++--- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/backend/src/middleware/email/emailMiddleware.js b/backend/src/middleware/email/emailMiddleware.js index 1a63b2c10..52bf25954 100644 --- a/backend/src/middleware/email/emailMiddleware.js +++ b/backend/src/middleware/email/emailMiddleware.js @@ -4,42 +4,38 @@ import { htmlToText } from 'nodemailer-html-to-text' import { resetPasswordMail, wrongAccountMail } from './templates/passwordReset' import { signupTemplate } from './templates/signup' -let sendMail -if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) { +const hasEmailConfig = CONFIG.SMTP_HOST && CONFIG.SMTP_PORT +const hasAuthData = CONFIG.SMTP_USERNAME && CONFIG.SMTP_PASSWORD + +let sendMail = () => {} +if (!hasEmailConfig) { + if (process.env.NODE_ENV !== 'test') { + // eslint-disable-next-line no-console + console.log('Warning: Email middleware will not try to send mails.') + } +} else { sendMail = async templateArgs => { - const transport = transporter() - transport.use( + const transporter = nodemailer.createTransport({ + host: CONFIG.SMTP_HOST, + port: CONFIG.SMTP_PORT, + ignoreTLS: CONFIG.SMTP_IGNORE_TLS, + secure: false, // true for 465, false for other ports + auth: hasAuthData && { + user: CONFIG.SMTP_USERNAME, + pass: CONFIG.SMTP_PASSWORD, + }, + }) + + transporter.use( 'compile', htmlToText({ ignoreImage: true, wordwrap: false, }), ) - await transport.sendMail({ - from: '"Human Connection" ', - ...templateArgs, - }) - } -} else { - sendMail = () => {} - if (process.env.NODE_ENV !== 'test') { - // eslint-disable-next-line no-console - console.log('Warning: Email middleware will not try to send mails.') - } -} -const transporter = () => { - const configs = { - host: CONFIG.SMTP_HOST, - port: CONFIG.SMTP_PORT, - ignoreTLS: CONFIG.SMTP_IGNORE_TLS, - secure: false, // true for 465, false for other ports + await transporter.sendMail(templateArgs) } - const { SMTP_USERNAME: user, SMTP_PASSWORD: pass } = CONFIG - if (user && pass) { - configs.auth = { user, pass } - } - return nodemailer.createTransport(configs) } const sendSignupMail = async (resolve, root, args, context, resolveInfo) => { @@ -50,15 +46,17 @@ const sendSignupMail = async (resolve, root, args, context, resolveInfo) => { return response } +const sendPasswordResetMail = async (resolve, root, args, context, resolveInfo) => { + const { email } = args + const { email: emailFound, nonce, name } = await resolve(root, args, context, resolveInfo) + const mailTemplate = emailFound ? resetPasswordMail : wrongAccountMail + await sendMail(mailTemplate({ email, nonce, name })) + return true +} + export default { Mutation: { - requestPasswordReset: async (resolve, root, args, context, resolveInfo) => { - const { email } = args - const { email: emailFound, nonce, name } = await resolve(root, args, context, resolveInfo) - const mailTemplate = emailFound ? resetPasswordMail : wrongAccountMail - await sendMail(mailTemplate({ email, nonce, name })) - return true - }, + requestPasswordReset: sendPasswordResetMail, Signup: sendSignupMail, SignupByInvitation: sendSignupMail, }, diff --git a/backend/src/middleware/email/templates/passwordReset.js b/backend/src/middleware/email/templates/passwordReset.js index c977594b5..c8617004b 100644 --- a/backend/src/middleware/email/templates/passwordReset.js +++ b/backend/src/middleware/email/templates/passwordReset.js @@ -13,6 +13,7 @@ export const resetPasswordMail = options => { actionUrl.searchParams.set('email', email) return { + from: '"Human Connection" ', to: email, subject, text: ` @@ -53,6 +54,7 @@ export const wrongAccountMail = options => { } = options const actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) return { + from: '"Human Connection" ', to: email, subject, text: ` diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index a6abdf6f2..d67c8f7ae 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -1,22 +1,22 @@ -import CONFIG from '../../../config' import fs from 'fs' import path from 'path' import mustache from 'mustache' +import CONFIG from '../../../config' const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8') -export const signupTemplate = options => { - const { - email, - nonce, - subject = 'Welcome to Human Connection!', - supportUrl = 'https://human-connection.org/en/contact/', - } = options +export const signupTemplate = ({ + email, + nonce, + subject = 'Willkommen, Bienvenue, Welcome to Human Connection!', + supportUrl = 'https://human-connection.org/en/contact', +}) => { const actionUrl = new URL('/registration/create-user-account', CONFIG.CLIENT_URI) actionUrl.searchParams.set('nonce', nonce) actionUrl.searchParams.set('email', email) return { + from: '"Human Connection" ', to: email, subject, html: mustache.render(signupHtml, { actionUrl, nonce, supportUrl }), From a304dcbfdfb613d6f229fe62f025479fe671e92e Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 00:06:57 +0100 Subject: [PATCH 15/21] add reset password template --- .../email/templates/resetPassword.html | 448 ++++++++++++++++++ .../middleware/email/templates/signup.html | 12 +- 2 files changed, 450 insertions(+), 10 deletions(-) create mode 100644 backend/src/middleware/email/templates/resetPassword.html diff --git a/backend/src/middleware/email/templates/resetPassword.html b/backend/src/middleware/email/templates/resetPassword.html new file mode 100644 index 000000000..8332b049e --- /dev/null +++ b/backend/src/middleware/email/templates/resetPassword.html @@ -0,0 +1,448 @@ + + + + + + + + + + Reset Password / Neues Passwort + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Human Connection gGmbH
Bahnhofstraße 11, 73235 Weilheim / + Teck
Germany
+

+
+ + + + + + +
+ + + diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 0837b0641..75a200085 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -8,7 +8,7 @@ - Welcome to Human Connection + Willkommen, Bienvenue, Welcome to Human Connection - - -

-

Oder du kopierst diesen Code in dein Browserfenster: {{{ nonce }}}

- -

–––––––––––––––––––––––––––––––––––––––––––––––

From 2bd7276523e1c0146d4a7519cbda09f3fa8999e6 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 00:14:13 +0100 Subject: [PATCH 16/21] improve padding --- .../email/templates/resetPassword.html | 16 ++++++++-------- .../src/middleware/email/templates/signup.html | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/backend/src/middleware/email/templates/resetPassword.html b/backend/src/middleware/email/templates/resetPassword.html index 8332b049e..162078c73 100644 --- a/backend/src/middleware/email/templates/resetPassword.html +++ b/backend/src/middleware/email/templates/resetPassword.html @@ -243,7 +243,7 @@ - + -
+ -
+ @@ -343,7 +343,7 @@ -
{{{ nonce }}}

Bis bald bei Human Connection!

-

– Dein Human Connection Team

+

– Dein Human Connection Team

+ -
+ - -
+
{{{ nonce }}}

See you soon on Human Connection!

-

– The Human Connection Team

+

– The Human Connection Team

diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 75a200085..baee449d2 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -253,7 +253,7 @@
+ -
+ -
+ @@ -365,7 +365,7 @@ - - - - diff --git a/backend/src/middleware/email/templates/templateBuilder.js b/backend/src/middleware/email/templates/templateBuilder.js index 8bf7dc438..fdeb47a89 100644 --- a/backend/src/middleware/email/templates/templateBuilder.js +++ b/backend/src/middleware/email/templates/templateBuilder.js @@ -42,7 +42,7 @@ export const wrongAccountTemplate = ({ email }) => { return { from, to: email, - subject: 'Falsche Mailadresse? | Wrong Email?', + subject: 'Falsche Mailadresse? | Wrong E-mail?', html: mustache.render(wrongAccountHtml, { actionUrl, supportUrl }), } } diff --git a/backend/src/middleware/email/templates/wrongAccount.html b/backend/src/middleware/email/templates/wrongAccount.html index cc3823ceb..b8e6f6f57 100644 --- a/backend/src/middleware/email/templates/wrongAccount.html +++ b/backend/src/middleware/email/templates/wrongAccount.html @@ -8,7 +8,7 @@ - Falsche Mailadresse? | Wrong Email? + Falsche Mailadresse? | Wrong E-mail?
wenn du Fragen hast.

Bis bald bei Human Connection!

-

– Dein Human Connection Team

+

– Dein Human Connection Team

+ - @@ -323,8 +323,8 @@ @@ -387,21 +387,13 @@
+ - @@ -275,7 +275,7 @@
+

See you soon on Human Connection!

-

– The Human Connection Team

+

– The Human Connection Team

From e45948f4f0785a455c1ff71f112eb337c26a6b13 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 00:23:51 +0100 Subject: [PATCH 17/21] use password reset template --- .../email/templates/passwordReset.js | 48 +++++-------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/backend/src/middleware/email/templates/passwordReset.js b/backend/src/middleware/email/templates/passwordReset.js index c8617004b..03f697200 100644 --- a/backend/src/middleware/email/templates/passwordReset.js +++ b/backend/src/middleware/email/templates/passwordReset.js @@ -1,13 +1,17 @@ +import fs from 'fs' +import path from 'path' +import mustache from 'mustache' import CONFIG from '../../../config' -export const resetPasswordMail = options => { - const { - name, - email, - nonce, - subject = 'Use this link to reset your password. The link is only valid for 24 hours.', - supportUrl = 'https://human-connection.org/en/contact/', - } = options +const passwordResetHtml = fs.readFileSync(path.join(__dirname, './resetPassword.html'), 'utf-8') + +export const resetPasswordMail = ({ + name, + email, + nonce, + subject = 'Neues Passwort / Reset Password', + supportUrl = 'https://human-connection.org/en/contact/', +}) => { const actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) actionUrl.searchParams.set('nonce', nonce) actionUrl.searchParams.set('email', email) @@ -16,33 +20,7 @@ export const resetPasswordMail = options => { from: '"Human Connection" ', to: email, subject, - text: ` -Hi ${name}! - -You recently requested to reset your password for your Human Connection account. -Use the link below to reset it. This password reset is only valid for the next -24 hours. - -${actionUrl} - -If you did not request a password reset, please ignore this email or contact -support if you have questions: - -${supportUrl} - -Thanks, -The Human Connection Team - -If you're having trouble with the link above, you can manually copy and -paste the following code into your browser window: - -${nonce} - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland - `, + html: mustache.render(passwordResetHtml, { actionUrl, name, nonce, supportUrl }), } } From b193e180c5d9d70c8d9e9aa5f927493026cb8458 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 00:42:42 +0100 Subject: [PATCH 18/21] add wrong account html template --- .../email/templates/passwordReset.js | 26 +- .../email/templates/resetPassword.html | 4 +- .../email/templates/wrongAccount.html | 448 ++++++++++++++++++ 3 files changed, 452 insertions(+), 26 deletions(-) create mode 100644 backend/src/middleware/email/templates/wrongAccount.html diff --git a/backend/src/middleware/email/templates/passwordReset.js b/backend/src/middleware/email/templates/passwordReset.js index 03f697200..0b57fc9d5 100644 --- a/backend/src/middleware/email/templates/passwordReset.js +++ b/backend/src/middleware/email/templates/passwordReset.js @@ -4,6 +4,7 @@ import mustache from 'mustache' import CONFIG from '../../../config' const passwordResetHtml = fs.readFileSync(path.join(__dirname, './resetPassword.html'), 'utf-8') +const wrongAccountHtml = fs.readFileSync(path.join(__dirname, './wrongAccount.html'), 'utf-8') export const resetPasswordMail = ({ name, @@ -35,29 +36,6 @@ export const wrongAccountMail = options => { from: '"Human Connection" ', to: email, subject, - text: ` -We received a request to reset the password to access Human Connection with your -email address, but we were unable to find an account associated with this -address. - -If you use Human Connection and were expecting this email, consider trying to -request a password reset using the email address associated with your account. -Try a different email: - -${actionUrl} - -If you do not use Human Connection or did not request a password reset, please -ignore this email. Feel free to contact support if you have further questions: - -${supportUrl} - -Thanks, -The Human Connection Team - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland - `, + html: mustache.render(wrongAccountHtml, { actionUrl, supportUrl }), } } diff --git a/backend/src/middleware/email/templates/resetPassword.html b/backend/src/middleware/email/templates/resetPassword.html index 162078c73..1b12702b4 100644 --- a/backend/src/middleware/email/templates/resetPassword.html +++ b/backend/src/middleware/email/templates/resetPassword.html @@ -8,7 +8,7 @@ - Reset Password / Neues Passwort + Reset Password | Neues Passwort + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + From a7d525deab849799cae9d4c11d76c6d149b61b0a Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 00:55:06 +0100 Subject: [PATCH 19/21] refactor password reset --- .../src/middleware/email/emailMiddleware.js | 7 ++- .../email/templates/passwordReset.js | 43 +++++++++---------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/backend/src/middleware/email/emailMiddleware.js b/backend/src/middleware/email/emailMiddleware.js index 52bf25954..af3d69c4a 100644 --- a/backend/src/middleware/email/emailMiddleware.js +++ b/backend/src/middleware/email/emailMiddleware.js @@ -1,13 +1,13 @@ import CONFIG from '../../config' import nodemailer from 'nodemailer' import { htmlToText } from 'nodemailer-html-to-text' -import { resetPasswordMail, wrongAccountMail } from './templates/passwordReset' +import { resetPasswordTemplate } from './templates/passwordReset' import { signupTemplate } from './templates/signup' const hasEmailConfig = CONFIG.SMTP_HOST && CONFIG.SMTP_PORT const hasAuthData = CONFIG.SMTP_USERNAME && CONFIG.SMTP_PASSWORD -let sendMail = () => {} +let sendMail = () => { } if (!hasEmailConfig) { if (process.env.NODE_ENV !== 'test') { // eslint-disable-next-line no-console @@ -49,8 +49,7 @@ const sendSignupMail = async (resolve, root, args, context, resolveInfo) => { const sendPasswordResetMail = async (resolve, root, args, context, resolveInfo) => { const { email } = args const { email: emailFound, nonce, name } = await resolve(root, args, context, resolveInfo) - const mailTemplate = emailFound ? resetPasswordMail : wrongAccountMail - await sendMail(mailTemplate({ email, nonce, name })) + await sendMail(resetPasswordTemplate({ emailFound, email, nonce, name })) return true } diff --git a/backend/src/middleware/email/templates/passwordReset.js b/backend/src/middleware/email/templates/passwordReset.js index 0b57fc9d5..d9da7a180 100644 --- a/backend/src/middleware/email/templates/passwordReset.js +++ b/backend/src/middleware/email/templates/passwordReset.js @@ -6,36 +6,33 @@ import CONFIG from '../../../config' const passwordResetHtml = fs.readFileSync(path.join(__dirname, './resetPassword.html'), 'utf-8') const wrongAccountHtml = fs.readFileSync(path.join(__dirname, './wrongAccount.html'), 'utf-8') -export const resetPasswordMail = ({ +const supportUrl = 'https://human-connection.org/en/contact/' +const from = '"Human Connection" ' + +export const resetPasswordTemplate = ({ name, email, + emailFound, nonce, - subject = 'Neues Passwort / Reset Password', - supportUrl = 'https://human-connection.org/en/contact/', }) => { - const actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) - actionUrl.searchParams.set('nonce', nonce) - actionUrl.searchParams.set('email', email) + let subject, htmlTemplate, actionUrl + + if (emailFound) { + subject = 'Neues Passwort | Reset Password' + htmlTemplate = passwordResetHtml + actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) + actionUrl.searchParams.set('nonce', nonce) + actionUrl.searchParams.set('email', email) + } else { + subject = 'Falsche Mailadresse? | Wrong Email?' + htmlTemplate = wrongAccountHtml + actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) + } return { - from: '"Human Connection" ', + from, to: email, subject, - html: mustache.render(passwordResetHtml, { actionUrl, name, nonce, supportUrl }), - } -} - -export const wrongAccountMail = options => { - const { - email, - subject = `We received a request to reset your password with this email address (${email})`, - supportUrl = 'https://human-connection.org/en/contact/', - } = options - const actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) - return { - from: '"Human Connection" ', - to: email, - subject, - html: mustache.render(wrongAccountHtml, { actionUrl, supportUrl }), + html: mustache.render(htmlTemplate, { actionUrl, name, nonce, supportUrl }), } } From e843edeb131a8017f3ef078608b133cdba4b84b1 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 01:15:52 +0100 Subject: [PATCH 20/21] unite email templates in templateBuilder --- .../src/middleware/email/emailMiddleware.js | 14 +-- .../email/templates/passwordReset.js | 38 --------- .../src/middleware/email/templates/signup.js | 24 ------ .../email/templates/templateBuilder.js | 48 +++++++++++ .../resolvers/passwordReset/emailTemplates.js | 85 ------------------- 5 files changed, 57 insertions(+), 152 deletions(-) delete mode 100644 backend/src/middleware/email/templates/passwordReset.js delete mode 100644 backend/src/middleware/email/templates/signup.js create mode 100644 backend/src/middleware/email/templates/templateBuilder.js delete mode 100644 backend/src/schema/resolvers/passwordReset/emailTemplates.js diff --git a/backend/src/middleware/email/emailMiddleware.js b/backend/src/middleware/email/emailMiddleware.js index af3d69c4a..e5b0678b8 100644 --- a/backend/src/middleware/email/emailMiddleware.js +++ b/backend/src/middleware/email/emailMiddleware.js @@ -1,13 +1,16 @@ import CONFIG from '../../config' import nodemailer from 'nodemailer' import { htmlToText } from 'nodemailer-html-to-text' -import { resetPasswordTemplate } from './templates/passwordReset' -import { signupTemplate } from './templates/signup' +import { + signupTemplate, + resetPasswordTemplate, + wrongAccountTemplate, +} from './templates/templateBuilder' const hasEmailConfig = CONFIG.SMTP_HOST && CONFIG.SMTP_PORT const hasAuthData = CONFIG.SMTP_USERNAME && CONFIG.SMTP_PASSWORD -let sendMail = () => { } +let sendMail = () => {} if (!hasEmailConfig) { if (process.env.NODE_ENV !== 'test') { // eslint-disable-next-line no-console @@ -48,8 +51,9 @@ const sendSignupMail = async (resolve, root, args, context, resolveInfo) => { const sendPasswordResetMail = async (resolve, root, args, context, resolveInfo) => { const { email } = args - const { email: emailFound, nonce, name } = await resolve(root, args, context, resolveInfo) - await sendMail(resetPasswordTemplate({ emailFound, email, nonce, name })) + const { email: userFound, nonce, name } = await resolve(root, args, context, resolveInfo) + const template = userFound ? resetPasswordTemplate : wrongAccountTemplate + await sendMail(template({ email, nonce, name })) return true } diff --git a/backend/src/middleware/email/templates/passwordReset.js b/backend/src/middleware/email/templates/passwordReset.js deleted file mode 100644 index d9da7a180..000000000 --- a/backend/src/middleware/email/templates/passwordReset.js +++ /dev/null @@ -1,38 +0,0 @@ -import fs from 'fs' -import path from 'path' -import mustache from 'mustache' -import CONFIG from '../../../config' - -const passwordResetHtml = fs.readFileSync(path.join(__dirname, './resetPassword.html'), 'utf-8') -const wrongAccountHtml = fs.readFileSync(path.join(__dirname, './wrongAccount.html'), 'utf-8') - -const supportUrl = 'https://human-connection.org/en/contact/' -const from = '"Human Connection" ' - -export const resetPasswordTemplate = ({ - name, - email, - emailFound, - nonce, -}) => { - let subject, htmlTemplate, actionUrl - - if (emailFound) { - subject = 'Neues Passwort | Reset Password' - htmlTemplate = passwordResetHtml - actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) - actionUrl.searchParams.set('nonce', nonce) - actionUrl.searchParams.set('email', email) - } else { - subject = 'Falsche Mailadresse? | Wrong Email?' - htmlTemplate = wrongAccountHtml - actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) - } - - return { - from, - to: email, - subject, - html: mustache.render(htmlTemplate, { actionUrl, name, nonce, supportUrl }), - } -} diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js deleted file mode 100644 index d67c8f7ae..000000000 --- a/backend/src/middleware/email/templates/signup.js +++ /dev/null @@ -1,24 +0,0 @@ -import fs from 'fs' -import path from 'path' -import mustache from 'mustache' -import CONFIG from '../../../config' - -const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8') - -export const signupTemplate = ({ - email, - nonce, - subject = 'Willkommen, Bienvenue, Welcome to Human Connection!', - supportUrl = 'https://human-connection.org/en/contact', -}) => { - const actionUrl = new URL('/registration/create-user-account', CONFIG.CLIENT_URI) - actionUrl.searchParams.set('nonce', nonce) - actionUrl.searchParams.set('email', email) - - return { - from: '"Human Connection" ', - to: email, - subject, - html: mustache.render(signupHtml, { actionUrl, nonce, supportUrl }), - } -} diff --git a/backend/src/middleware/email/templates/templateBuilder.js b/backend/src/middleware/email/templates/templateBuilder.js new file mode 100644 index 000000000..8bf7dc438 --- /dev/null +++ b/backend/src/middleware/email/templates/templateBuilder.js @@ -0,0 +1,48 @@ +import fs from 'fs' +import path from 'path' +import mustache from 'mustache' +import CONFIG from '../../../config' + +const from = '"Human Connection" ' +const supportUrl = 'https://human-connection.org/en/contact' + +const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8') +const passwordResetHtml = fs.readFileSync(path.join(__dirname, './resetPassword.html'), 'utf-8') +const wrongAccountHtml = fs.readFileSync(path.join(__dirname, './wrongAccount.html'), 'utf-8') + +export const signupTemplate = ({ email, nonce }) => { + const actionUrl = new URL('/registration/create-user-account', CONFIG.CLIENT_URI) + actionUrl.searchParams.set('nonce', nonce) + actionUrl.searchParams.set('email', email) + + return { + from, + to: email, + subject: 'Willkommen, Bienvenue, Welcome to Human Connection!', + html: mustache.render(signupHtml, { actionUrl, supportUrl }), + } +} + +export const resetPasswordTemplate = ({ email, nonce, name }) => { + const actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) + actionUrl.searchParams.set('nonce', nonce) + actionUrl.searchParams.set('email', email) + + return { + from, + to: email, + subject: 'Neues Passwort | Reset Password', + html: mustache.render(passwordResetHtml, { actionUrl, name, nonce, supportUrl }), + } +} + +export const wrongAccountTemplate = ({ email }) => { + const actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) + + return { + from, + to: email, + subject: 'Falsche Mailadresse? | Wrong Email?', + html: mustache.render(wrongAccountHtml, { actionUrl, supportUrl }), + } +} diff --git a/backend/src/schema/resolvers/passwordReset/emailTemplates.js b/backend/src/schema/resolvers/passwordReset/emailTemplates.js deleted file mode 100644 index 8508adccc..000000000 --- a/backend/src/schema/resolvers/passwordReset/emailTemplates.js +++ /dev/null @@ -1,85 +0,0 @@ -import CONFIG from '../../../config' - -export const from = '"Human Connection" ' - -export const resetPasswordMail = options => { - const { - name, - email, - code, - subject = 'Use this link to reset your password. The link is only valid for 24 hours.', - supportUrl = 'https://human-connection.org/en/contact/', - } = options - const actionUrl = new URL('/password-reset/change-password', CONFIG.CLIENT_URI) - actionUrl.searchParams.set('code', code) - actionUrl.searchParams.set('email', email) - - return { - to: email, - subject, - text: ` -Hi ${name}! - -You recently requested to reset your password for your Human Connection account. -Use the link below to reset it. This password reset is only valid for the next -24 hours. - -${actionUrl} - -If you did not request a password reset, please ignore this email or contact -support if you have questions: - -${supportUrl} - -Thanks, -The Human Connection Team - -If you're having trouble with the link above, you can manually copy and -paste the following code into your browser window: - -${code} - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland - `, - } -} - -export const wrongAccountMail = options => { - const { - email, - subject = `We received a request to reset your password with this email address (${email})`, - supportUrl = 'https://human-connection.org/en/contact/', - } = options - const actionUrl = new URL('/password-reset/request', CONFIG.CLIENT_URI) - return { - to: email, - subject, - text: ` -We received a request to reset the password to access Human Connection with your -email address, but we were unable to find an account associated with this -address. - -If you use Human Connection and were expecting this email, consider trying to -request a password reset using the email address associated with your account. -Try a different email: - -${actionUrl} - -If you do not use Human Connection or did not request a password reset, please -ignore this email. Feel free to contact support if you have further questions: - -${supportUrl} - -Thanks, -The Human Connection Team - -Human Connection gemeinnützige GmbH -Bahnhofstr. 11 -73235 Weilheim / Teck -Deutschland - `, - } -} From b25d552193269a4c58f689523394fb519b3bee91 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Sep 2019 09:52:47 +0100 Subject: [PATCH 21/21] follow @Tirokk and @datenbrei suggestions --- .../email/templates/resetPassword.html | 14 ++++---- .../middleware/email/templates/signup.html | 33 ++++++++----------- .../email/templates/templateBuilder.js | 2 +- .../email/templates/wrongAccount.html | 18 +++++----- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/backend/src/middleware/email/templates/resetPassword.html b/backend/src/middleware/email/templates/resetPassword.html index 1b12702b4..e0dde53e5 100644 --- a/backend/src/middleware/email/templates/resetPassword.html +++ b/backend/src/middleware/email/templates/resetPassword.html @@ -8,7 +8,7 @@ - Reset Password | Neues Passwort + Neues Passwort | Reset Password
- Here is your signup link. + Dein Anmeldelink. | Here is your signup link.
@@ -261,9 +261,9 @@

Willkommen bei Human Connection!

-

Danke, dass du dich angemeldet hast – wir freuen uns, dich dabei zu haben. Jetzt - fehlt nur noch eine Kleinigkeit, bevor wir gemeinsam die Welt verbessern können... Bitte bestätige - deine E-Mail Adresse:

+

Danke, dass Du dich angemeldet hast – wir freuen uns, Dich dabei zu haben. Jetzt + fehlt nur noch eine Kleinigkeit, bevor wir gemeinsam die Welt verbessern können ... Bitte bestätige + Deine E-Mail Adresse:

Bestätige - deine E-Mail Adresse + Deine E-Mail Adresse
@@ -299,10 +299,10 @@
-

Falls du dich nicht selbst bei Falls Du Dich nicht selbst bei Human Connection angemeldet hast, schau doch mal vorbei! Wir sind ein gemeinnütziges Aktionsnetzwerk – von Menschen für Menschen.

-

PS: Wenn du keinen Account bei uns möchtest, kannst du diese +

PS: Wenn Du keinen Account bei uns möchtest, kannst Du diese E-Mail einfach ignorieren. ;)

-

Melde dich gerne bei - unserem Support Team wenn du Fragen hast.

+

Melde Dich gerne bei + unserem Support Team, wenn Du Fragen hast.

Bis bald bei Human Connection!

– Dein Human Connection Team

@@ -374,7 +374,7 @@ style="margin: 0 0 10px 0; font-family: Lato, sans-serif; font-size: 25px; line-height: 30px; color: #333333; font-weight: normal;"> Welcome to Human Connection!

Thank you for joining our cause – it's awesome to have you on board. There's - just one tiny step missing before we can start shaping the world together... Please confirm your + just one tiny step missing before we can start shaping the world together ... Please confirm your e-mail address by clicking the button below:

Confirm - your email address + your e-mail address
-

-

Or you can copy this code and paste it in your browser window: {{{ nonce }}}

-

–––––––––––––––––––––––––––––––––––––––––––––––

@@ -422,7 +414,8 @@

If you didn't sign up for Human Connection we recommend you to check it out! It's a social network from people for people who want to connect and change the world together.

-

PS: If you ignore this email we will not create an account for +

PS: If you ignore this e-mail we will not create an account + for you. ;)