1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-18 12:31:12 +02:00

get preact files into root

This commit is contained in:
Kushagra Gour
2018-06-16 14:56:14 +05:30
parent f5d2b5d1a7
commit dfcd5bc505
57 changed files with 18452 additions and 40 deletions

43
src/auth.js Normal file
View File

@@ -0,0 +1,43 @@
import {
trackEvent
} from './analytics';
import firebase from 'firebase/app'
export const auth = {
logout() {
firebase.auth().signOut();
},
login(providerName) {
var provider;
if (providerName === 'facebook') {
provider = new firebase.auth.FacebookAuthProvider();
} else if (providerName === 'twitter') {
provider = new firebase.auth.TwitterAuthProvider();
} else if (providerName === 'google') {
provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/userinfo.profile');
} else {
provider = new firebase.auth.GithubAuthProvider();
}
return firebase
.auth()
.signInWithPopup(provider)
.then(function () {
trackEvent('fn', 'loggedIn', providerName);
// Save to recommend next time
window.db.local.set({
lastAuthProvider: providerName
});
})
.catch(function (error) {
utils.log(error);
if (error.code === 'auth/account-exists-with-different-credential') {
alert(
'You have already signed up with the same email using different social login'
);
}
});
}
}