Szakdolgozat/frontend/firestore.rules

30 lines
990 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;
}
2021-01-29 00:46:40 +00:00
function getUserData() {
2020-12-14 23:29:45 +00:00
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data;
2021-01-29 00:46:40 +00:00
}
2020-12-14 23:29:45 +00:00
//Felhasználói adatok kezelése
match /users/{user} {
2021-01-29 00:46:40 +00:00
allow read, write: if sameUser(user) && request.auth.uid == request.resource.data.author_uid;
2020-12-14 23:29:45 +00:00
}
2021-01-29 00:46:40 +00:00
//Adminisztrátoroknak mindent lehet
2020-12-14 23:29:45 +00:00
match /data/{document=**} {
allow get, list, create, update, delete: if auth.token.admin;
2020-12-14 23:29:45 +00:00
}
//Diákok megnézhetik a tárgy adatait
match /data/subjects/{subject=**} {
2020-12-14 23:29:45 +00:00
allow get, list: if request.auth.uid in resource.data.students;
}
2021-01-29 00:46:40 +00:00
//Az oktatók módosithatják a követelményeket
match /data/subjects/{subject}/requirements/{requirement=**} {
allow read, write: if request.auth.uid in resource.data.teachers;
}
}
2020-12-14 23:29:45 +00:00
}