Last active
July 24, 2017 10:33
-
-
Save paulbreslin/1f02769fdd77328d4adec538fc25d1ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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