-
-
Save christianmalek/f0d8d6c69ce2b50a976e2fe87b4f3280 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