I have a flutter app where I have signed in users successfully and no errors are thrown up. But, when I attempt FirebaseAuth.instance.signOut() in one of my buttons, it signs the user out but throws up this error. I have attached my cloud firestore rules below.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /merchants/{document=**} {
allow read;
}
match /all_merchants/{document=**} {
allow read;
}
match /Types/{document=**} {
allow read;
}
match /Promotions/{document=**} {
allow read;
}
match /search_types/{document=**} {
allow read;
}
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
match /{document=**}{
allow read, update, create, delete: if request.auth.uid == userId;
}
}
match /users/{email} {
allow read, update, delete: if request.auth.token.email == email;
allow create: if request.auth.token.email != null;
match /{document=**}{
allow read, update, create, delete: if request.auth.token.email == email;
}
}
}
}
(edit): My Flutter code for the button is as below:
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class SignOut extends StatelessWidget {
FirebaseAuth auth = FirebaseAuth.instance;
@override
Widget build(BuildContext context) {
GestureDetector(
onTap: (){
setState(() {
auth.signOut();
});
},
child: ListTile(
dense: true,
leading: Icon(Icons.exit_to_app, color: Colors.red[600], size: 25,),
title: Text('Sign Out',
style: TextStyle(fontFamily: 'Lato', fontSize: 18, fontWeight: FontWeight.w500),),
trailing: Icon(Icons.arrow_forward_ios, color: Colors.black, size: 19,),
),
);
}
}