当前位置: 动力学知识库 > 问答 > 编程问答 >

json - Data access restrictions in Firebase Database

问题描述:

My Firebase Database structure looks something like this:

appRoot

|

`- students

|

`- x3l5WagYrOX8IDcvZnCkbP2ZmZy3

| |

| `- Name: "Carlos Silva"

| `- Age: "17"

| `- Username: "Carlos06"

| `- Password: "Carlos"

| `- Classes

| |

| `- C1

| `- Teacher_Name: "Daniel Volker"

`- Teacher_Uid: "s1g6AatOr1K2PDfjZnL45I3BmUdx"

| `- Subject: "Physics"

| `- Date: "02/05/2017"

| `- Status: "Confirmed"

|

`- teachers

|

`- s1g6AatOr1K2PDfjZnL45I3BmUdx

|

`- Name: "Daniel Volker"

`- Subject: "Physics"

`- Username: "DanielVK"

`- Password: "123123"

`- Classes

|

`- C1

`- Student_Name: "Carlos Silva"

`- Student_Uid: "x3l5WagYrOX8IDcvZnCkbP2ZmZy3"

`- Age: "17"

`- Date: "02/05/2017"

`- Status: "Confirmed"

Each student and teacher is represented by their auth.uid. I would like to set some security rules so that students can read teachers' Name and Subject, but they can't read their Username and Password. Besides, I want both the student and the teacher to be able to modify the Status of the class (which can be canceled or confirmed) or to completely remove it. The problem is that I don't know how to set a rule in a way that the student can write only to a specific path in the teacher's node and vice versa. Is this possible?

I am new to firebase rules, any help will be much appreciated.

分享给朋友:
您可能感兴趣的文章:
随机阅读: