diff --git a/src/App.vue b/src/App.vue index d8174645..692cbf9f 100755 --- a/src/App.vue +++ b/src/App.vue @@ -70,7 +70,11 @@ export default { return; } - firebase.auth().getRedirectResult().then(({ user }) => { + firebase.auth().getRedirectResult().then(({ additionalUserInfo, user }) => { + if (additionalUserInfo && additionalUserInfo.isNewUser) { + this.$store.dispatch('SEND_WELCOME_EMAIL', additionalUserInfo); + } + if (user) { this.init(user); } else { diff --git a/src/store/actions.js b/src/store/actions.js index 12e9e312..237498e6 100755 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -62,4 +62,18 @@ export default { }).catch(reject); }); }, + + SEND_WELCOME_EMAIL() { + return new Promise((resolve, reject) => { + const payload = { + address: 'urbanbooth@gmail.com', + template_id: 'welcome', + }; + + axios.post(`${FIREBASE_URL}/email`, payload) + .then(({ data }) => { + resolve(data); + }).catch(reject); + }); + }, };