我想做的是从云Firestore中检索数据,只为登录应用程序的用户。我正在使用Auth Firebase,我构建了一个方法来从一个名为“user”的特定集合中检索一些文档,它工作了,它显示了登录的用户的正确名称,并将用户注册到我的表单中。现在我正在用另一个表单收集另一个名为“ShippingAddress”的Firestore集合,“ShippingAddress”集合中的文档应该显示到应用程序中,只针对登录到应用程序的特定用户。但这并没有发生,任何用户登录我得到相同的数据从所有用户除了姓名和电子邮件地址。这是我的代码:
final databaseReference = Firestore.instance;
Future<QuerySnapshot> getData() async {
var firebaseUser = await FirebaseAuth.instance.currentUser();
return await Firestore.instance
.collection("user")
.where("email", isEqualTo: firebaseUser.email)
.getDocuments();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: getData(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
Stream(),
],
);
});
} else if (snapshot.data == null) {
return Center(child: CircularProgressIndicator());
}
return Center(child: CircularProgressIndicator());
},
);
}
}
class Stream extends StatefulWidget {
@override
_StreamState createState() => _StreamState();
}
class _StreamState extends State<Stream> {
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('shippingAddress').snapshots(),
builder: (context, snapshot) {
// if (!snapshot.hasData) return Text('Loading data please Wait');
return Column(
children: <Widget>[
Container(
height: 1000,
child: ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Color(0xFF1f2032),
elevation: 15,
child: Container(
width: 60,
height: 60,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(
snapshot.data.documents[index]['alias'],
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
],
),
),
);
},
),
),
],
);
},
);
}
}
**can you share the Database image?
如果需要特定的用户信息,则需要使用此方法
Firestore.instance
.collection('talks')
.document('document-name')
.get()
.then((DocumentSnapshot ds) {
// use ds as a snapshot
});
我正在为我的flutter应用程序使用JWT进行身份验证。我可以成功地登录和注销,但问题是令牌何时过期。我是否应该将用户的用户名/密码存储在安全存储中,然后获取新的令牌?
我正在考虑将应用程序迁移到Cloud Foundry,因为我厌倦了独自管理我的服务器。在我当前的应用程序中,我使用Spring Security和会话来处理我的用户登录。然而,我对如何更改我的代码一无所知,因此Cloud Foundry的多个实例支持我的用户以某种无状态的方式登录(但使用令牌)。我已经研究了UAA,但这似乎是针对云铸造用户的,而不是我的应用程序的用户。 类似OAUTH2的东西似乎是
问题内容: 以下是允许用户将数据存储到Firestore中的代码。问题是,登录到该应用程序的所有用户都可以查看上传的数据。我如何才能仅允许当前登录的用户仅存储其帐户的数据? 对于Firebase数据库,我使用以下代码(有效,但不适用于Firestore) FirebaseUser用户= FirebaseAuth.getInstance()。getCurrentUser(); 字符串userId =
我正在将flutter应用程序从Firebase实时数据库迁移到Firestore。我在聊天应用程序中更新这段代码时遇到麻烦,因为firestore没有FireBaseAnimatedList。 旧代码: 现在只有错误是在动画中。我有错误:
当使用signInWithEmailAndPassword()API在firebase中进行身份验证时,我无法获得有效的“当前”用户。 我使用用户名和密码登录应用程序 我一旦登录,用户就会被带到主页 我试图获取用户的UID,但是没有返回有效的用户。调用发生在异步函数中,如下所示: 当前用户为空。 知道是什么引起的吗?
我正在设计一个SAAS应用程序,每个用户拥有多租户数据库,每个数据库拥有唯一的订阅用户子域。当saas应用程序的订阅用户将更多用户添加到他们的仪表板或产品中时,问题就会出现,因此如何处理他们从我们的主应用程序页面的登录,因为他们的数据库条目将只在他们的管理员数据库中。或者我应该为所有用户使用一个全局数据库来处理登录? 我正在寻找任何有价值的建议,我是一个新手,刚刚开始在SAAS应用程序工作 谢谢