在我注销后,我尝试再次登录,是的,它登录成功,但问题是,我开始收到错误cloud_firestore/permission-denied,但当我重新启动我的应用程序时,它再次正常工作。我遗漏了什么?
PS:我正在用Google登录。
这是我的登录代码:
Future signInWithGoogle() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
// Obtain the auth details from the request
final GoogleSignInAuthentication googleAuth =
await googleUser!.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
// Once signed in, return the UserCredential
await _auth.signInWithCredential(credential);
}这是我的注销代码:
await _googleSignIn.signOut().then((value) async {
await widget.firebaseAuth.signOut().then((value) {
Navigator.pop(context);
});
}).onError((error, stackTrace) {
print(error);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("ERROR!! TRY AGAIN"),
));
});发布于 2021-09-02 01:39:20
cloud_firestore/permission-denied错误来自Firestore (数据库),而不是Firebase身份验证。
最有可能的是,您的代码中有一些要求用户登录的实时侦听程序,一旦您注销用户,这些侦听程序就会被数据库拒绝。
您可以通过取消订阅来remove the listeners,也可以忽略错误,因为在发生此错误后,侦听器也会自动取消。
https://stackoverflow.com/questions/69021632
复制相似问题