From 5e86b25a690a326b4aad5d0b90d3ce7bd91df9d2 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Sun, 17 Sep 2017 14:54:48 +0530 Subject: [PATCH] fix(auth): Remove reset password endpoint --- common/models/user.js | 45 +-------------------------------------- server/utils/url-utils.js | 2 +- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index 47f3f992e1..3304f234d4 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -175,7 +175,7 @@ module.exports = function(User) { var mailOptions = { type: 'email', to: user.email, - from: 'team@freecodecamp.org', + from: getEmailSender(), subject: 'Welcome to freeCodeCamp!', protocol: getProtocol(), host: getHost(), @@ -363,49 +363,6 @@ module.exports = function(User) { }); }); - User.on('resetPasswordRequest', function(info) { - if (!isEmail(info.email)) { - console.error(createEmailError()); - return null; - } - let url; - const host = User.app.get('host'); - const { id: token } = info.accessToken; - if (process.env.NODE_ENV === 'development') { - const port = User.app.get('port'); - url = `http://${host}:${port}/reset-password?access_token=${token}`; - } else { - url = - `http://freecodecamp.org/reset-password?access_token=${token}`; - } - - // the email of the requested user - debug(info.email); - // the temp access token to allow password reset - debug(info.accessToken.id); - // requires AccessToken.belongsTo(User) - var mailOptions = { - to: info.email, - from: 'team@freecodecamp.org', - subject: 'Password Reset Request', - text: ` - Hello,\n\n - This email is confirming that you requested to - reset your password for your freeCodeCamp account. - This is your email: ${ info.email }. - Go to ${ url } to reset your password. - \n - Happy Coding! - \n - ` - }; - - return User.app.models.Email.send(mailOptions, function(err) { - if (err) { console.error(err); } - debug('email reset sent'); - }); - }); - User.beforeRemote('login', function(ctx, notUsed, next) { const { body } = ctx.req; if (body && typeof body.email === 'string') { diff --git a/server/utils/url-utils.js b/server/utils/url-utils.js index b0c686233a..0f997e7009 100644 --- a/server/utils/url-utils.js +++ b/server/utils/url-utils.js @@ -2,7 +2,7 @@ const isDev = process.env.NODE_ENV !== 'production'; const isBeta = !!process.env.BETA; export function getEmailSender() { - return process.env.EMAIL_SENDER || 'team@freecodecamp.org'; + return process.env.SES_MAIL_FROM || 'team@freecodecamp.org'; } export function getPort() {