【发布时间】:2021-03-03 10:48:35
【问题描述】:
我有一个 Flutter 应用程序,我已成功登录用户并且没有抛出任何错误。但是,当我在我的一个按钮中尝试 FirebaseAuth.instance.signOut() 时,它会注销用户但会引发此错误。我在下面附上了我的云存储规则。
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;
}
}
}
}
(编辑):我的按钮的 Flutter 代码如下:
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,),
),
);
}
}
【问题讨论】:
-
我认为该错误与安全规则无关。请编辑问题以显示未按预期方式运行的代码,以及导致错误的原因。
-
已添加!谢谢
标签: firebase flutter dart google-cloud-firestore firebase-authentication