fix(auth): Remove reset password endpoint

This commit is contained in:
Mrugesh Mohapatra
2017-09-17 14:54:48 +05:30
parent 4c016216b9
commit 5e86b25a69
2 changed files with 2 additions and 45 deletions

View File

@ -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') {

View File

@ -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() {