rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { 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; } } }