fix(auth): Remove reset password endpoint
This commit is contained in:
@ -175,7 +175,7 @@ module.exports = function(User) {
|
|||||||
var mailOptions = {
|
var mailOptions = {
|
||||||
type: 'email',
|
type: 'email',
|
||||||
to: user.email,
|
to: user.email,
|
||||||
from: 'team@freecodecamp.org',
|
from: getEmailSender(),
|
||||||
subject: 'Welcome to freeCodeCamp!',
|
subject: 'Welcome to freeCodeCamp!',
|
||||||
protocol: getProtocol(),
|
protocol: getProtocol(),
|
||||||
host: getHost(),
|
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) {
|
User.beforeRemote('login', function(ctx, notUsed, next) {
|
||||||
const { body } = ctx.req;
|
const { body } = ctx.req;
|
||||||
if (body && typeof body.email === 'string') {
|
if (body && typeof body.email === 'string') {
|
||||||
|
@ -2,7 +2,7 @@ const isDev = process.env.NODE_ENV !== 'production';
|
|||||||
const isBeta = !!process.env.BETA;
|
const isBeta = !!process.env.BETA;
|
||||||
|
|
||||||
export function getEmailSender() {
|
export function getEmailSender() {
|
||||||
return process.env.EMAIL_SENDER || 'team@freecodecamp.org';
|
return process.env.SES_MAIL_FROM || 'team@freecodecamp.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPort() {
|
export function getPort() {
|
||||||
|
Reference in New Issue
Block a user