From d77e9fd4118af1a57afb955bfb0abb51a1b3d064 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Sun, 17 Sep 2017 15:26:15 +0530 Subject: [PATCH] fix(user): Remove remote method on user create --- common/models/user.js | 41 ------------------- server/views/emails/a-extend-user-welcome.ejs | 19 --------- 2 files changed, 60 deletions(-) delete mode 100644 server/views/emails/a-extend-user-welcome.ejs diff --git a/common/models/user.js b/common/models/user.js index 3304f234d4..28483950b9 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -164,47 +164,6 @@ module.exports = function(User) { }); }); - // send welcome email to new camper - User.afterRemote('create', function({ req, res }, user, next) { - debug('user created, sending email'); - if (!user.email || !isEmail(user.email)) { return next(); } - const redirect = req.session && req.session.returnTo ? - req.session.returnTo : - '/'; - - var mailOptions = { - type: 'email', - to: user.email, - from: getEmailSender(), - subject: 'Welcome to freeCodeCamp!', - protocol: getProtocol(), - host: getHost(), - port: getPort(), - template: path.join( - __dirname, - '..', - '..', - 'server', - 'views', - 'emails', - 'a-extend-user-welcome.ejs' - ), - redirect: '/email-signin' - }; - - debug('sending welcome email'); - return user.verify(mailOptions, function(err) { - if (err) { return next(err); } - req.flash('success', { - msg: [ 'Congratulations ! We\'ve created your account. ', - 'Please check your email. We sent you a link that you can ', - 'click to verify your email address and then login.' - ].join('') - }); - return res.redirect(redirect); - }); - }); - User.observe('before save', function({ instance: user }, next) { if (user) { // Some old accounts will not have emails associated with theme diff --git a/server/views/emails/a-extend-user-welcome.ejs b/server/views/emails/a-extend-user-welcome.ejs deleted file mode 100644 index a86828caf8..0000000000 --- a/server/views/emails/a-extend-user-welcome.ejs +++ /dev/null @@ -1,19 +0,0 @@ -Greetings from San Francisco! - -Thank you for joining our community. - -Please verify your email by following the link below: - -<%= verifyHref %> - -Feel free to email us at this address if you have any questions about freeCodeCamp. -
-
-And if you have a moment, check out our blog: https://medium.freecodecamp.org. -
-
-Good luck with the challenges! - -Thanks, -The freeCodeCamp Team. -team@freecodecamp.com