Skip to content

Instantly share code, notes, and snippets.

@E01T
Forked from zenorocha/basic.md
Created March 22, 2018 17:04
Show Gist options
  • Select an option

  • Save E01T/c71f44fce0c6c204ed6f3359245b852a to your computer and use it in GitHub Desktop.

Select an option

Save E01T/c71f44fce0c6c204ed6f3359245b852a to your computer and use it in GitHub Desktop.
New Firebase Auth vs Old Firebase Auth

Create account

firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
	console.log(error);
});

Sign in

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
	console.log(error);
});

Sign out

firebase.auth().signOut().then(function() {
  // Sign-out successful.
}, function(error) {
	console.log(error);
});

Delete user

?

Sign In with Popup

var provider = new firebase.auth.FacebookAuthProvider();

provider.addScope('user_birthday');

firebase.auth().signInWithPopup(provider).then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign In with Redirect

var provider = new firebase.auth.FacebookAuthProvider();

provider.addScope('user_birthday');

firebase.auth().signInWithRedirect(provider);

firebase.auth().getRedirectResult().then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign Out

firebase.auth().signOut().then(function() {
  // Sign-out successful.
}, function(error) {
  console.log(error);
});

Sign In with Popup

var provider = new firebase.auth.GoogleAuthProvider();

provider.addScope('https://www.googleapis.com/auth/plus.login');

firebase.auth().signInWithPopup(provider).then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign In with Redirect

var provider = new firebase.auth.GoogleAuthProvider();

provider.addScope('https://www.googleapis.com/auth/plus.login');

firebase.auth().signInWithRedirect(provider);

firebase.auth().getRedirectResult().then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign Out

firebase.auth().signOut().then(function() {
  // Sign-out successful.
}, function(error) {
  console.log(error);
});

Sign In with Popup

var provider = new firebase.auth.TwitterAuthProvider();

firebase.auth().signInWithPopup(provider).then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign In with Redirect

var provider = new firebase.auth.TwitterAuthProvider();

firebase.auth().signInWithRedirect(provider);

firebase.auth().getRedirectResult().then(function(result) {
	console.log(result);
}).catch(function(error) {
	console.log(error);
});

Sign Out

firebase.auth().signOut().then(function() {
  // Sign-out successful.
}, function(error) {
  console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment