user762579
user762579

Reputation:

Firebase: update user's profile not working

I am updating the Firebase user profile photoURL it's upadted in the store but not in the Firebase users db... when I signout then signin with this user, the photoURL is NOT changed

here is my store action

    updateProfilePhotoURL ({commit}, payload) {
      const updateFBUserProfile = async (commit, payload) => {
        commit(types.SET_LOADING, true)
        let db = firebase.database()
        const updatedData = {
          photoURL: payload.photoURL
        }
        // Update the Firebase user profile too...
        await db.ref('users/' + payload.uid).update(updatedData)
        // Update the store profile too...
        commit(types.UPDATE_PROFILE_PHOTO_URL, updatedData.photoURL)
        return 'ok'
      }
      return new Promise((resolve, reject) => {
        updateFBUserProfile(commit, payload)
          .then(result => {
            commit(types.SET_LOADING, false)
            resolve(result)
          }, error => {
            console.log('ERROR: ', error)
            reject(error)
          })
      })
    }

where am I wrong ?

thanks for feedback

Upvotes: 1

Views: 1643

Answers (1)

Max Sinev
Max Sinev

Reputation: 6019

According to question comments - I think your user has no permissions to write to db. You can check it with firebase.auth().currentUser or check your Rules for database in Firebase Console.

Upvotes: 1

Related Questions