I have made modifications to my code to be able to work with these rules:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
The problem was the completion handler didn't work properly. The account was logged out before the documents were deleted. (Is this because the firebase functions are asynchronous??? or run in the background instead of the Main Actor??) Idk...
I fixed the problem by fixing the completion handler and checking if the deletion process is completed before singout()
Go to **Database** -> **Rules** :
**Then changed below rules**
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
**to below**
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}