firebase - 为什么在我测试更新或创建时,firebase 模拟器会抛出无效的参数错误?

标签 firebase google-cloud-firestore firebase-security

这是我的错误:
运行模拟时出错 — 错误:simulator.rules 行 [10],列 [13]。找不到函数错误:名称:[get].;错误:提供给调用的参数无效。函数:[get],参数:["||invalid_argument||"]

当我运行它时,我已经使用了我可以在网上找到的所有资源,但没有发现任何有用的东西(当我只使用 isSignedIn() 时,允许读取和创建)......请帮我一点帮助。

service cloud.firestore {
	match /databases/{database}/documents{
    match /users/{documents} {     
	 function isSignedIn() {
         return request.auth != null;
    }
	 function getRole(admin){
   		return get(/databases/$(database)/documents/users.[request.auth.uid]).data.admin;   		
   }        
     allow read: if true; 
     allow write: if getRole(admin) == true;    
    }
  }  
}


Here is my db

最佳答案

在尝试在 getRole 函数中获取用户的角色之前,您需要检查该用户是否已通过身份验证。发生异常是因为 request.auth.uid 为空。
还要检查 users.[request.auth.uid] 是有效路径。

关于firebase - 为什么在我测试更新或创建时,firebase 模拟器会抛出无效的参数错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52898999/

相关文章:

javascript - Firestore 事务在 Cloud Functions 中找不到数据

firebase - 如何撤销身份验证 token ?

android - 在 Cloud Firestore 中如何创建一个只创建一次的安全规则

firebase - Google +帐户与Firebase关联时的操作

node.js - Firebase Firestore 事务处理极其缓慢(3-4 分钟)

javascript - Firebase Web 应用程序的管理员 View : How To

android - 如何获取recyclerview Item位置的文档id?

firebase - 用于在用户之间共享文档的 Firestore 数据库规则和结构

swift - 处理来自 firebase 的 Null ref

firebase - 如何计算 Firestore 中分页和筛选集合的元素总数