Szakdolgozat/firestore.rules

25 lines
888 B
Text
Raw Normal View History

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
2020-12-14 23:29:45 +00:00
function sameUser(user) {
return request.auth != null && request.auth.uid == user;
}
function getUserData() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data;
}
//Felhasználói adatok kezelése
match /users/{user} {
allow create: if sameUser(user) && request.auth.uid == request.resource.data.author_uid;
allow get, list, update, delete: if sameUser(user) && request.auth.uid == resource.data.author_uid;
}
//Adminoknak mindent lehet
match /data/{document=**} {
allow get, list, create, update, delete: if getUserData().isAdmin == true;
}
//Diákok megnézhetik a kurzus adatait
match /data/courses/{course} {
allow get, list: if request.auth.uid in resource.data.students;
}
}
2020-12-14 23:29:45 +00:00
}