![](/img/trans.png)
[英]How I can get the right data for specific user when I did auth flow (log in, log out) with Flutter Firestore?
[英]Why do I get an error when I log out with Firebase Auth?
這是我的注銷代碼:
onPressed: () async {
await FirebaseAuth.instance.signOut();
await widget.checkLogin();
},
這是我的 CheckLogin function:
checkLogin() async {
if (FirebaseAuth.instance.currentUser != null) {
login = true;
setState(() {});
} else {
login = false;
setState(() {});
}
}
注銷后它給我的錯誤如下:
Unhandled Exception: [firebase_database/permission-denied] Client doesn't have permission to access the desired data.
通過各種嘗試,我意識到問題出在這些代碼行中,但我不知道如何修復...
if (FirebaseAuth.instance.currentUser != null) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
DatabaseReference ref = FirebaseDatabase.instance.ref("temp");
if (FirebaseAuth.instance.currentUser != null) {
ref.onValue.listen((DatabaseEvent event) {
final snapshot = event.snapshot.value;
if (snapshot != null) {
Object? temp = snapshot;
if (mounted) {
setState(() {});
}
}
});
}
});
}
任何人都知道如何解決?
Go 到您的 Firebase 控制台並像這樣更新您的規則
Select 側面菜單中的數據庫 --> Select 上面選項卡中的規則 --> 像這樣更新你的規則
{
"rules": {
".read": true,
".write": true
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.