1
votes

Does Firebase automatically add users that login via a social provider like facebook to the firebase Authentication / User database?

In other words if Christine signs in via Facebook, does firebase also store her email address, first name, etc. in the Authentication / User database that she would be stored in if she signed up via the regular signup form?

2

2 Answers

2
votes

If you are talking about the Firebase Authentication list then yes. See here => Authentication database

But if you want to save some user data in the realtime or firestore database you have to do it yourself. Best way to do that in my opinion is with Firebase Functions but you could also do it in the client after a successful register/login.

This is a simplified version of the function I would use in the client directly after login. I'd usually add a bunch of custom properties like last login, etc..

writeUserToDB(user: User) {
  this.db.object('users/'+ user.uid).valueChanges().take(1).subscribe( val => {
    let newUser = val == null ? user : val;      
    this.db.object('users/' + newUser.uid ).update(newUser)
  });
}

Also some basic rules for the /users node.

    "users": {
      "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid"
     }
1
votes

When a user signs in to Firebase Authentication with a social provider, their profile is automatically stored in Firebase Authentication itself. This information (including their email address) is available through the Firebase Authentication SDKs, including the server-side Admin SDKs.

No data is automatically stored in the Firebase Database. If you want to do that, you can easily do it yourself though.