I have a firestore collection like this:
- raffle-holder
- {uid}
- games
- {game}
- {game data}
- {game}
- user
- data
- {user data}
- data
- {raffle-holder data}
- games
- {uid}
My current security rules are as follows:
match /raffle-holder/{uid} {
allow read: if request.auth.uid == uid;
match /games/{document=**} {
allow read, write: if request.auth.uid == uid;
}
match /user/data {
allow read,write: if request.auth.uid == uid;
}
}
I tried the rule simulator with one of my authenticated users and it works fine, but when I try to get data from /raffle-holder/{uid}/games/{game}
then I get a Missing or insufficient permissions
error. Also, I verified that my variables are correct and need help debugging why this error is appearing.
void getUserTixs() {
final userId = FirebaseAuth.instance.currentUser!.uid;
final gameRef = db
.collection("raffle-holder")
.doc(userId)
.collection("games")
.doc(widget.gameId);
gameRef.get().then((value) {
if (value.exists) {
gameRef.snapshots().listen((event) {
if (event.data() != null) {
setState(() {
userTixs = event.data()!['tixPurchased'];
});
}
});
}
}, onError: (e) {
print(e);
});
}