Я пытаюсь дать пользователям-читателям возможность редактировать / записывать некоторые дочерние узлы: см. БД ниже (Статус и Назначено). В последнее время я добавил следующее правило:
Строка 5 || root.child ( 'writeByAll'). имеетРебенка (auth.uid)) "
К сожалению, это дает пользователю для чтения все права на запись, если эта строка удалена, пользователь имеет право на запись, но я не могу получить правильный результат
Я посмотрел пост Правила базы данных Firebase для групп , но не могу поместить его в контекст.
Любая помощь будет принята с благодарностью, это для диссертационного проекта. (Исходные правила здесь: Как предоставить доступ на чтение-чтение / запись к определенным UID из Firebase Auth и Database )
{
"rules": {
"stores": {
".read": "auth != null && (root.child('readUsers').hasChild(auth.uid) || root.child('readWriteUsers').hasChild(auth.uid))",
".write": "auth != null && (root.child('readWriteUsers').hasChild(auth.uid) || root.child('writeByAll').hasChild(auth.uid))",
"Status" : {
".read": "auth != null && root.child('writeByAll').hasChild(auth.uid)",
".write": "auth != null && root.child('writeByAll').hasChild(auth.uid)",
},
},
"readUsers": {
".read": "auth != null && root.child('readUsers').hasChild(auth.uid)",
".write": false
},
"writeByAll": {
".read": "auth != null && root.child('writeByAll').hasChild(auth.uid)",
".write": false
}
}
}
Ниже приведен мой класс задачи редактирования -
database = FirebaseDatabase.getInstance().getReference("stores").child("Store 01").child("Task List"); // Reference Database
spinnerType = findViewById(R.id.typeSpinner);
status = findViewById(R.id.statusView);
findViewById(R.id.saveTaskbtn).setOnClickListener(saveTask);
// Retrieving data from background
Intent intent = getIntent();
String passedType = intent.getStringExtra("passType");
String passedStatus = intent.getStringExtra("passStatus")
spinnerType.setSelection(((ArrayAdapter<String>)spinnerType.getAdapter()).getPosition(passedType));
spinnerStatus.getAdapter()).getPosition(passedStatus));
status.setText(passedStatus);
}//OnCreate
View.OnClickListener saveTask = new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = getIntent();
final String key = intent.getStringExtra("passKey");
DatabaseReference typeRef = ref.child("Type");
DatabaseReference statusRef = ref.child("Status")
String type = spinnerType.getSelectedItem().toString();
String statusName = status.getText().toString();
assignedRef.setValue(assignee);
typeRef.setValue(type);
statusRef.setValue(statusName).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {