do not send welcome email if user already exists

This commit is contained in:
Matteo Pagliazzi
2016-09-28 19:23:07 +02:00
parent bfc7b9d3e8
commit d67b9e5688

View File

@@ -163,7 +163,9 @@ api.registerLocal = {
// Clean previous email preferences and send welcome email // Clean previous email preferences and send welcome email
EmailUnsubscription EmailUnsubscription
.remove({email: savedUser.auth.local.email}) .remove({email: savedUser.auth.local.email})
.then(() => sendTxnEmail(savedUser, 'welcome')); .then(() => {
if (!existingUser) sendTxnEmail(savedUser, 'welcome');
});
if (!existingUser) { if (!existingUser) {
res.analytics.track('register', { res.analytics.track('register', {
@@ -310,7 +312,9 @@ api.loginSocial = {
EmailUnsubscription EmailUnsubscription
.remove({email: savedUser.auth[network].emails[0].value.toLowerCase()}) .remove({email: savedUser.auth[network].emails[0].value.toLowerCase()})
.exec() .exec()
.then(() => sendTxnEmail(savedUser, 'welcome')); // eslint-disable-line max-nested-callbacks .then(() => {
if (!existingUser) sendTxnEmail(savedUser, 'welcome');
}); // eslint-disable-line max-nested-callbacks
} }
if (!existingUser) { if (!existingUser) {