Im trying to delete data from firebase. I am logged into the VueJS host application, and have the firebase rules set as below, but it is still giving me a permission denied error. The commented out code gives the same result.
Rules:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write, delete: if true;
}
}
}
Function:
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)
})
},
Console:
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)