实时Firebase删除权限被拒绝

时间:2018-12-06 11:55:15

标签: firebase vue.js

我正在尝试从Firebase中删除数据。我已登录到VueJS主机应用程序,并按如下所示设置了Firebase规则,但仍给我一个权限被拒绝的错误。注释掉的代码给出相同的结果。

规则:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write, delete: if true;
    }
  }
}

功能:

test(trackID) {
            console.log(firebase.auth().currentUser.uid)
            var usersRef = firebase.database().ref(`users/${firebase.auth().currentUser.uid}/tracks/${trackID}`)
            // let usersRef = db.collection('users').doc(`${firebase.auth().currentUser.uid}/tracks/${trackID}`)
            usersRef.remove().then(() => {
            // usersRef.delete().then(() => {
                console.log('Document successfully deleted!')
            }).catch(function(error) {
                console.error('Error removing document: ', error)
            })
        },

控制台:

Account.vue?e7d7:82 Error removing document:  Error: PERMISSION_DENIED: Permission denied
at eval (index.cjs.js?3523:13076)
at exceptionGuard (index.cjs.js?3523:690)
at Repo.callOnCompleteCallback (index.cjs.js?3523:13067)
at eval (index.cjs.js?3523:12844)
at eval (index.cjs.js?3523:12019)
at PersistentConnection.onDataMessage_ (index.cjs.js?3523:12052)
at Connection.onDataMessage_ (index.cjs.js?3523:11337)
at Connection.onPrimaryMessageReceived_ (index.cjs.js?3523:11331)
at WebSocketConnection.eval [as onMessage] (index.cjs.js?3523:11232)
at WebSocketConnection.appendFrame_ (index.cjs.js?3523:10837)

0 个答案:

没有答案