prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

UpdateAuth should update profile like when logging in #811

Open esbenvb opened 4 years ago

esbenvb commented 4 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

I want to update the user profile document in firestore, whenever I update the firebase auth data. For instance, when I update the displayName and photoURL in of a Firebase.User.

Currently, a firebase.login() will copy the displayName and map the photoURL to the avatarUrl field of users/xxxxxx

However, when I update the Firebase auth profile, either using your firebase.updateAuth() or the original firebase.auth().currentUser.updateProfile(), the avatarUrl and providerData fields are not updated, before I logout and in again.

What is the expected behavior?

I expect that if I call the firebase.updateAuth() helper function in order to update the profile, it will do the same data syncing from firebase auth to the users/xxx document, as when I log in.

The changes made by the user (i.e. new name or profile picture) needs to be effective before logging out and in.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

    "react": "16.8.3",
    "react-native": "0.59.10",
    "react-native-firebase": "^5.3.1",
    "react-redux": "^5.1.1",
    "react-redux-firebase": "^2.2.6",
    "redux": "^4.0.1",
    "redux-devtools-extension": "^2.13.8",
    "redux-firestore": "^0.9.0",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0"

I also tested with newest 2.4.1, same issue

illuminist commented 4 years ago

You need to pass true to second parameter of firebase.updateAuth() for it to sync profile data with database

firebase.updateAuth({displayName:'...', profileA: '...', profileB: '...'}, true)

It will call firebase.updateProfile to do an actual update on your database.

vitalii4reva commented 4 years ago

Maybe, you should add it to the documentation?