简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM