Closed Twansparant closed 2 years ago
I think this is caused by the fact that the fl_id
& schema
variables are not present in the resource.data
object in the view
security rule, which apparently is used in the Flamelink remove
lookup query.
allow read: if isContentPermitted(resource.data._fl_meta_.schema, 'view', resource.data._fl_meta_.fl_id);
If I set both to true, the remove does work:
allow read, delete: if true;
For now I use the Firebase delete query:
const batch = firebaseApp
.firestore()
.batch();
const docs = await firebaseApp
.firestore()
.collection('fl_content')
.where('_fl_meta_.fl_id', '==', user?.uid)
.where('_fl_meta_.schema', '==', 'appUsers')
.get();
docs.forEach(doc => {
batch.delete(doc.ref);
});
await batch.commit()
.then(() => {
console.log('App user removed succesfully');
})
.catch(error => {
console.log(error);
});
Which works with my custom security rules!
Hi @Twansparant
Do you get the entry when you try the following
const logEntry = async () => {
const user = firebaseApp.auth().currentUser;
try {
const entry = await flamelinkApp.content.get({
schemaKey: 'appUsers',
entryId: user?.uid
});
console.log(entry);
} catch (error) {
console.log(error);
}
};
logEntry();
Yes I do!
And just to check, does the authenticated user have permission to delete entries based on their permissions in set in Flamelink?
Could you also please share your rule function for isContentPermitted.
Closing due to inactivity. Unable to reproduce behavior.
Hi there,
I use Flamelink in combination with Firebase authentication to view/create/update/delete documents in a
appUsers
schema. I also added custom firestore security rules like described here #86.I add content to the schema with the
entryId
set to the user's authentication uid. This is all working great, well for the view/create part at least, somehow the delete part does not work.I'm using the remove function from the Flamelink JavaScript SDK:
These are my custom security rules, for debugging purposes I temporary always allowed delete.
No matter what I try, it always logs
'App user removed succesfully'
, while the entry is still in the Cloud Firestore and the CMS. Theuser?.uid
definitely has the correct value.What am I missing here? Thanks!