Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud firestore Firestore问题,以身份验证模式恢复我的用户_Google Cloud Firestore - Fatal编程技术网

Google cloud firestore Firestore问题,以身份验证模式恢复我的用户

Google cloud firestore Firestore问题,以身份验证模式恢复我的用户,google-cloud-firestore,Google Cloud Firestore,我因身份验证问题被困了三天 当我试图恢复数据库中的用户时(代码1),会出现一条错误消息(代码2)。在我看来,我似乎在身份验证级别断开了连接。我还附加了我的请求代码(代码3)来读取数据库中的“用户”文件,因为在我看来,错误来自于此 代码1: 1 rules_version = '2'; 2 service cloud.firestore { 3 match /databases/{database}/documents { 4 match /users /{userId=**} {

我因身份验证问题被困了三天 当我试图恢复数据库中的用户时(代码1),会出现一条错误消息(代码2)。在我看来,我似乎在身份验证级别断开了连接。我还附加了我的请求代码(代码3)来读取数据库中的“用户”文件,因为在我看来,错误来自于此

代码1:


1
rules_version = '2';
2
service cloud.firestore {
3
  match /databases/{database}/documents {
4
    match /users /{userId=**} {
5
      allow create
6
      allow read : if request.auth != null 
7
    }
8
    match /cities/{city=**}{
9
        allow write : if true
10
        allow read : if true
11
      }
12
  }
13
}
代码2:

2021-03-06 14:25:18.395 18921-18921/com.croustibat.ampc93 W/com.croustibat.ampc93.CityFragmentPresentation: Echec de chargement des utilisateurs
    com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
        at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:117)
        at com.google.firebase.firestore.core.EventManager.onError(EventManager.java:166)
        at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:589)
        at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:425)
        at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99)
        at com.google.firebase.firestore.remote.RemoteStore.processTargetError(RemoteStore.java:562)
        at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(RemoteStore.java:446)
        at com.google.firebase.firestore.remote.RemoteStore.access$100(RemoteStore.java:53)
        at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(RemoteStore.java:176)
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:108)
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38)
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1(AbstractStream.java:119)
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$Lambda$2.run(Unknown Source:4)
        at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:110)
        at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:125)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: io.grpc.StatusException: PERMISSION_DENIED: Missing or insufficient permissions.
        at io.grpc.Status.asException(Status.java:541)
        at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:115)
        at com.google.firebase.firestore.core.EventManager.onError(EventManager.java:166) 
        at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:589) 
        at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:425) 
        at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99) 
        at com.google.firebase.firestore.remote.RemoteStore.processTargetError(RemoteStore.java:562) 
        at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(RemoteStore.java:446) 
        at com.google.firebase.firestore.remote.RemoteStore.access$100(RemoteStore.java:53) 
        at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(RemoteStore.java:176) 
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:108) 
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38) 
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1(AbstractStream.java:119) 
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$Lambda$2.run(Unknown Source:4) 
        at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67) 
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:110) 
        at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:125) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643) 
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229) 
        at java.lang.Thread.run(Thread.java:923) 
2021-03-06 14:25:18.425 18921-18921/com.croustibat.ampc93 D/com.croustibat.ampc93.CityFragmentPresentation: Conversion réussie !!!
代码3:

fun onDisplayDataFirestoreToUser() {
        db.collection("users").whereNotEqualTo("$currentUser", null)
            .get()
            .addOnSuccessListener {
                it.forEach {
                    val user = it.toObject<User>()
                    users.add(user)
                }
            }
            .addOnFailureListener {
                Log.w(TAG, "Echec de chargement des utilisateurs", it)
            }
    }
fun-onDisplayDataFirestoreToUser(){
db.collection(“用户”)。whereNotEqualTo($currentUser),null)
.get()
.addOnSuccessListener{
这是forEach{
val user=it.toObject()
用户。添加(用户)
}
}
.addOnFailureListener{
Log.w(标签“Echec使用费扣款”,it)
}
}

请帮帮我,我完全卡住了

你的规则有点乱,这是一个在模拟器中运行的清理版本

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId=**} {
      allow create: if true;
      allow read: if request.auth != null;
    }
        
    match /cities/{city=**} {
      allow write: if true;
      allow read: if true;
    }
  }
}

我建议您更新上述规则,然后使用“规则操场”进行测试。这至少可以排除您的安全规则的问题。

我确实刚刚更改了此错误,但相同的问题仍然存在。我的回答是,您的规则存在一些小问题,并且上述问题在模拟器中进行了测试。