gpt4 book ai didi

flutter - 使用手机进行身份验证时如何修复 'user unauthenticated' firebase 存储

转载 作者:行者123 更新时间:2023-12-05 02:39:40 26 4
gpt4 key购买 nike

Firestore 的新手,似乎无法解决我遇到的问题。我正在用手机注册用户,然后提示用户在应用程序中编辑数据。但是,我遇到了错误,不知道如何解决。

错误:

I/flutter ( 7502): [firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.

W/Firestore( 7502): (23.0.3) [WriteStream]: (b2291d0) Stream closed with status: Status{code=NOT_FOUND, description=No document to update:

projects/blahblah/databases/(default)/documents/users/CrxXOi8vajhUYfevbPbMRjAHQqrv5, cause=null}.

E/flutter ( 7502): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)]

Unhandled Exception: [cloud_firestore/not-found] Some requested document was not found.

身份验证工作正常,因为我在用户中看到了具有 uid 的用户。但是,不在 Firestore 集合“用户”中。我的规则很简单:

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {

match /users/{id} {
allow read, delete, update, create: if request.auth != null;
}}}

我的存储规则设置为:

 rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}}

编辑个人资料的方法是:

  String currentUid() {
return firebaseAuth.currentUser.uid;
}

updateProfile(
{File image,
String username,
String email,
String sex,
String dob,
String phone}) async {
DocumentSnapshot doc = await usersRef.doc(currentUid()).get();
var users = UserModel.fromJson(doc.data());
users.username = username;
users.email = email;
users.phone = phone;
users.dob = dob;
users.sex = sex;

if (image != null) {
users.photoUrl = await uploadImage(profilePic, image);
}
await usersRef.doc(currentUid()).update(
{'username': username, 'photoUrl': users.photoUrl, 'phone': phone,
'dob': dob, 'email': email, 'sex': sex});
return true;
}

非常感谢帮助!

最佳答案

我终于了解到,在开发初期不建议强制执行 AppCheck 存储访问。取消强制执行 AppCheck 进行存储,它成功了!从现在开始会看他们的视频!

关于flutter - 使用手机进行身份验证时如何修复 'user unauthenticated' firebase 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68989929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com