Skip to content

Instantly share code, notes, and snippets.

@paulbreslin
Last active July 24, 2017 10:33
Show Gist options
  • Save paulbreslin/1f02769fdd77328d4adec538fc25d1ea to your computer and use it in GitHub Desktop.
Save paulbreslin/1f02769fdd77328d4adec538fc25d1ea to your computer and use it in GitHub Desktop.
firebase.auth().onAuthStateChanged( user => {
if (user) {
// If user state changes and 'user' exists, check Firebase Database for user
const userReference = db.ref(`users/${user.uid}`);
userReference.once('value', snapshot => {
if (!snapshot.val()) {
// User does not exist, create user entry
userReference.set({
email: user.email,
displayName: user.displayName
});
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment