Remove error catch and use update method
This commit is contained in:
committed by
Berkeley Martinez
parent
26c1389c3a
commit
fd442c55bb
@ -556,7 +556,7 @@ module.exports = function(User) {
|
|||||||
renderSignUpEmail : renderSignInEmail;
|
renderSignUpEmail : renderSignInEmail;
|
||||||
|
|
||||||
// create a temporary access token with ttl for 1 hour
|
// create a temporary access token with ttl for 1 hour
|
||||||
user.createAccessToken({ ttl: 60 * 60 * 1000 }, (err, token) => {
|
return user.createAccessToken({ ttl: 60 * 60 * 1000 }, (err, token) => {
|
||||||
if (err) { throw err; }
|
if (err) { throw err; }
|
||||||
|
|
||||||
const { id: loginToken } = token;
|
const { id: loginToken } = token;
|
||||||
@ -579,14 +579,19 @@ module.exports = function(User) {
|
|||||||
} else {
|
} else {
|
||||||
console.log('~~~~\n' + mailOptions.text + '~~~~\n');
|
console.log('~~~~\n' + mailOptions.text + '~~~~\n');
|
||||||
}
|
}
|
||||||
user.emailAuthLinkTTL = token.created;
|
const emailAuthLinkTTL = token.created;
|
||||||
user.save(err =>{ if (err) { throw err; }});
|
this.update$({
|
||||||
});
|
emailAuthLinkTTL
|
||||||
|
})
|
||||||
|
.do(() => {
|
||||||
|
this.emailAuthLinkTTL = emailAuthLinkTTL;
|
||||||
|
});
|
||||||
|
|
||||||
return dedent`
|
return dedent`
|
||||||
If you entered a valid email, a magic link is on its way.
|
If you entered a valid email, a magic link is on its way.
|
||||||
Please follow that link to sign in.
|
Please follow that link to sign in.
|
||||||
`;
|
`;
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.map((msg) => {
|
.map((msg) => {
|
||||||
if (msg) { return msg; }
|
if (msg) { return msg; }
|
||||||
@ -594,12 +599,6 @@ module.exports = function(User) {
|
|||||||
Oops, something is not right, please try again later.
|
Oops, something is not right, please try again later.
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
|
||||||
debug(error);
|
|
||||||
return Observable.throw(
|
|
||||||
'Oops, something went wrong, please try again later.'
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.toPromise();
|
.toPromise();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user