In my Flutter app I am reading data from a document in the Cloud Firestore as this
Widget _createStampInFromOfficeWidget() {
final userDocumentStream = ref.watch(userStreamProvider);
return userDocumentStream.when(
data: (data) {
try {
bool signedIn = data['Signed In'];
bool workingRemotely = data['Working Remotely'];
return _stampedInOrOutTile(signedIn, workingRemotely);
} catch (error) {
return const ErrorText(errorText: 'Couldn't retrieve data');
}
},
error: (error, stack) {
developer.log('Error: $error');
return const ErrorText(errorText: 'Couldn't retrieve data');
},
loading: () {
return const Loading();
},
);
}
I am reading data from a user document, the rules for which I’ve defined like this
match /users/{userID} {
allow write, read: if request.auth != null && userID== request.auth.uid;
}
When I log in to the app for the first time, I am able to retrieve the data with no issue, but if I log out, then log in again, I recieve the error
"[cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation."
However when I turn off my app, and then turn it on again I’m able to retrieve the data without any error again whatsoever.
I don’t understand why I the permission handling rules works correctly when I first login, starts working when I re-login and it starts working correctly again after