refactor(code): cleanup and rebase
This commit is contained in:
committed by
Berkeley Martinez
parent
5c56a1e78c
commit
0ce30409c0
@ -355,7 +355,6 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
User.on('resetPasswordRequest', function(info) {
|
User.on('resetPasswordRequest', function(info) {
|
||||||
if (!isEmail(info.email)) {
|
if (!isEmail(info.email)) {
|
||||||
console.error(createEmailError());
|
console.error(createEmailError());
|
||||||
@ -399,8 +398,6 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> Remove reset-password logic
|
|
||||||
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') {
|
||||||
@ -570,7 +567,11 @@ module.exports = function(User) {
|
|||||||
};
|
};
|
||||||
return User.findOrCreate$({ where: { email }}, userObj)
|
return User.findOrCreate$({ where: { email }}, userObj)
|
||||||
.map(([ err, user, isCreated ]) => {
|
.map(([ err, user, isCreated ]) => {
|
||||||
if (err) { throw err; }
|
if (err) {
|
||||||
|
return dedent`
|
||||||
|
Oops, something is not right, please try again later.
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
const minutesLeft = getWaitPeriod(user.emailAuthLinkTTL);
|
const minutesLeft = getWaitPeriod(user.emailAuthLinkTTL);
|
||||||
if (minutesLeft) {
|
if (minutesLeft) {
|
||||||
@ -592,15 +593,13 @@ module.exports = function(User) {
|
|||||||
|
|
||||||
const { id: loginToken } = token;
|
const { id: loginToken } = token;
|
||||||
const loginEmail = user.email;
|
const loginEmail = user.email;
|
||||||
const host = isDev ?
|
|
||||||
'http://localhost:3000' : 'https://freecodecamp.com';
|
|
||||||
const mailOptions = {
|
const mailOptions = {
|
||||||
type: 'email',
|
type: 'email',
|
||||||
to: user.email,
|
to: user.email,
|
||||||
from: 'Team@freecodecamp.com',
|
from: 'Team@freecodecamp.com',
|
||||||
subject: 'freeCodeCamp - Authentication Request!',
|
subject: 'Free Code Camp - Authentication Request!',
|
||||||
text: renderAuthEmail({
|
text: renderAuthEmail({
|
||||||
host,
|
|
||||||
loginEmail,
|
loginEmail,
|
||||||
loginToken
|
loginToken
|
||||||
})
|
})
|
||||||
@ -620,16 +619,14 @@ module.exports = function(User) {
|
|||||||
this.emailAuthLinkTTL = emailAuthLinkTTL;
|
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(() => {
|
.map((msg) => {
|
||||||
return dedent`
|
if (msg) { return msg; }
|
||||||
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`
|
return dedent`
|
||||||
Oops, something is not right, please try again later.
|
Oops, something is not right, please try again later.
|
||||||
`;
|
`;
|
||||||
|
Reference in New Issue
Block a user