具有功能的Firestore安全规则返回未知错误

时间:2019-04-14 14:13:55

标签: firebase google-cloud-firestore firebase-security-rules

我有一个用户集合:

 const otherAppNavigator = createStackNavigator({//all of this are not in TabNavigator
dashboard: {
    screen: Dashboard,
},

userProfile: {
    screen: UserProfile
},

onGoingPickup: {
    screen: OnGoingPickup
},
 });

    const TabNavigator = createBottomTabNavigator({
    home: otherAppNavigator,//<<<<<<<<<<
    about:foo,

       }
    )

const MainNavigator = createSwitchNavigator({
    firstPage: {//it's not in TabNavigator<<<<<<<<<<<<<<<<<<<<<<<<<<
        screen: Login,
    },
    verification: {//its not in TabNavigator<<<<<<<<<<<<<<<<<<<<<<<<
        screen: verification
    },
    dashboard: {
        screen: TabNavigator
    }
})

export default createAppContainer(MainNavigator); //the main navigator is which you bind in here 

和ShoppingLists的集合:

Sub AddLinks2()
    Const LinkRow As Long = 5
    Dim cell As Range, list As Collection
    Set list = getExplanations
    With ThisWorkbook.Worksheets("Calcs")
        For Each cell In .Range(.Cells(LinkRow, 1), .Cells(LinkRow, Columns.Count).End(xlToLeft))
            On Error Resume Next
            list.Item cell.Text
            If Err.Number = 0 Then AddHyperlink cell, list(cell.Text)
            On Error GoTo 0
        Next
    End With
End Sub

Function getExplanations() As Collection
    Const LinkRow As Long = 5
    Dim cell As Range, list As New Collection

    With ThisWorkbook.Worksheets("Info")
        For Each cell In .Range(.Cells(1, 2), .Cells(.Rows.Count, 2).End(xlUp))
            On Error Resume Next
            list.Add cell, cell.Text
            On Error GoTo 0
        Next
    End With
    Set getExplanations = list
End Function

Sub AddHyperlink(Anchor As Range, Target As Range)
    Dim SubAddress As String
    SubAddress = Split(Target.Address(0, 0, xlA1, True), "]")(1)
    ActiveSheet.Hyperlinks.Add Anchor:=Anchor, Address:="", SubAddress:=SubAddress
End Sub

我想限制读取/更新访问权限,以便只有属于特定组的人才能编辑/读取同一组中的文档。

我尝试使用以下规则查看docs,但是在Firabase控制台模拟器中,我收到“未知错误”,并且对此没有任何控制台提示:

users:
   userUid:
       group: "group_1"
       name: "Paul"
   userUid:
       group: "group_1"
       name: "Gregor"
   userUid:
       group: "group_2"
       name: "Mary"

1 个答案:

答案 0 :(得分:0)

您没有在规则中正确使用get()。您正在将字符串路径传递到涉及集合和文档的文档,但是get()要求传递一个路径对象,该对象1)不是字符串,并且2)前缀为/databases/$(database)/documents。您应该read the documentation on accessing other documents看一些示例,例如:

service cloud.firestore {
  match /databases/{database}/documents {
    match /cities/{city} {
      // Make sure a 'users' document exists for the requesting user before
      // allowing any writes to the 'cities' collection
      allow create: if exists(/databases/$(database)/documents/users/$(request.auth.uid))

      // Allow the user to delete cities if their user document has the
      // 'admin' field set to 'true'
      allow delete: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true
    }
  }
}
相关问题