From 5c56a1e78cbad925f3605e09410224ca2d24f04c Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Tue, 7 Feb 2017 01:33:09 +0530 Subject: [PATCH] Update email views and notifications --- common/models/user.js | 24 ++++++++++---------- server/boot/user.js | 2 +- server/views/emails/user-request-sign-in.ejs | 10 ++++---- server/views/emails/user-request-sign-up.ejs | 14 +++++++----- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index c32786942e..11e90d2c46 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -570,11 +570,7 @@ module.exports = function(User) { }; return User.findOrCreate$({ where: { email }}, userObj) .map(([ err, user, isCreated ]) => { - if (err) { - return dedent` - Oops, something is not right, please try again later. - `; - } + if (err) { throw err; } const minutesLeft = getWaitPeriod(user.emailAuthLinkTTL); if (minutesLeft) { @@ -596,13 +592,15 @@ module.exports = function(User) { const { id: loginToken } = token; const loginEmail = user.email; - + const host = isDev ? + 'http://localhost:3000' : 'https://freecodecamp.com'; const mailOptions = { type: 'email', to: user.email, from: 'Team@freecodecamp.com', subject: 'freeCodeCamp - Authentication Request!', text: renderAuthEmail({ + host, loginEmail, loginToken }) @@ -622,14 +620,16 @@ module.exports = function(User) { this.emailAuthLinkTTL = emailAuthLinkTTL; }); - return dedent` - If you entered a valid email, a magic link is on its way. - Please follow that link to sign in. - `; }); }) - .map((msg) => { - if (msg) { return msg; } + .map(() => { + return dedent` + If you entered a valid email, a magic link is on its way. + Please follow that link to sign in. + `; + }) + .catch(err => { + if (err) { debug(err); } return dedent` Oops, something is not right, please try again later. `; diff --git a/server/boot/user.js b/server/boot/user.js index 53a334ef96..9d1f16c39b 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -258,7 +258,7 @@ module.exports = function(app) { return res.redirect('/'); } - return User.requestAuthLink(req.body.email, 'user-request-sign-in.ejs') + return User.requestAuthLink(req.body.email) .then(msg => { return res.status(200).send({ message: msg }); }) diff --git a/server/views/emails/user-request-sign-in.ejs b/server/views/emails/user-request-sign-in.ejs index bdd9e5c921..e5cec71ae7 100644 --- a/server/views/emails/user-request-sign-in.ejs +++ b/server/views/emails/user-request-sign-in.ejs @@ -1,12 +1,14 @@ Greetings from San Francisco! -You can now sign in to freeCodeCamp, without a password. Just follow the link below: +Please follow the link below, and sign in to freeCodeCamp instantly: -https://freecodecamp.com/passwordless-auth?email=<%= loginEmail %>&token=<%= loginToken %> +<%= host %>/passwordless-auth?email=<%= loginEmail %>&token=<%= loginToken %> + +This above link is valid for 15 minutes. IMPORTANT NOTE: -You can simply delete or ignore this email, if you did not make any such request. -Do not share this email with anyone, doing so may give them access to your account. +If you did not make any such request, simply delete or ignore this email. +Do not share this email with anyone, doing so will give them access to your account. Good luck with the challenges! diff --git a/server/views/emails/user-request-sign-up.ejs b/server/views/emails/user-request-sign-up.ejs index be92535b80..514b81ae39 100644 --- a/server/views/emails/user-request-sign-up.ejs +++ b/server/views/emails/user-request-sign-up.ejs @@ -1,19 +1,21 @@ Greetings from San Francisco! Welcome to freeCodeCamp. We've created a new account for you. -To verify and start using your profile just follow the link below: +Please verify and start using your profile by following the link below: -https://freecodecamp.com/passwordless-auth?email=<%= loginEmail %>&token=<%= loginToken %> +<%= host %>/passwordless-auth?email=<%= loginEmail %>&token=<%= loginToken %> -Next steps: -1. Visit the settings page and link your account to Github. +This above link is valid for 15 minutes. + +And when you have a moment: +1. Visit the settings page and link your account to GitHub. 2. Follow our Medium Publication: https://medium.freecodecamp.com 3. Checkout our forum: https://forum.freecodecamp.com 4. Join the conversation: https://gitter.im/FreeCodeCamp/FreeCodeCamp IMPORTANT NOTE: -You can simply delete or ignore this email, if you did not make any such request. -Do not share this email with anyone, doing so may give them access to your account. +If you did not make any such request, simply delete or ignore this email. +Do not share this email with anyone, doing so will give them access to your account. Good luck with the challenges!