1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-10-21 08:26:21 +02:00
Files
php-web-maker/src/auth.js
2018-01-13 12:06:07 +05:30

29 lines
789 B
JavaScript

window.logout = function logout() {
firebase.auth().signOut();
};
function 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() {})
.catch(function(error) {
alert(
'You have already signed up with the same email using different social login'
);
utils.log(error);
});
}
window.login = login;