Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. service cloud.firestore {
  2. match /databases/{database}/documents {
  3.  
  4. function isAdmin() {
  5. return get(/databases/$(database)/documents/access/$(request.auth.token.email)).data.permission == "admin";
  6. }
  7.  
  8. match /meetings/{meetingId} {
  9. function correctUserMeeting() {
  10. return get(/databases/$(database)/documents/access/$(request.auth.token.email)).data.obj[get(/databases/$(database)/documents/meetings/$(meetingId)).data.groupId] == "leader"
  11. }
  12. }
  13. allow read: if correctUserMeeting() || isAdmin()
  14. allow write: if isAdmin() || correctUserMeeting()
  15. }
  16.  
  17. match /access/{userId} {
  18. function correctEmail() {
  19. return request.auth.token.email == userId || get(/databases/$(database)/documents/access/$(request.auth.token.email)).data != null;
  20. }
  21.  
  22. allow read: if correctEmail() || isAdmin();
  23. allow write: if correctEmail() || isAdmin();
  24. }
  25.  
  26. match /groups/{groupsId} {
  27.  
  28. function correctEmail2() {
  29. return get(/databases/$(database)/documents/access/$(request.auth.token.email)).data[groupsId] == "leader"
  30. || get(/databases/$(database)/documents/access/$(request.auth.token.email)).data.groupsId == "leader";
  31. }
  32.  
  33. allow read: if true
  34. allow write: if isAdmin()
  35.  
  36. match /meetings/{meetingId} {
  37. allow read: if correctEmail2() || isAdmin();
  38. allow write: if isAdmin() || correctEmail2();
  39. }
  40. }
  41.  
  42. match /users/{userId}{
  43. allow read, write: if isAdmin() || get(/databases/$(database)/documents/access/$(request.auth.token.email)).data != null;
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement