Skip to content

Commit

Permalink
🔒 Update firebase security rules
Browse files Browse the repository at this point in the history
  • Loading branch information
leodr committed Feb 8, 2021
1 parent 3b0e0b5 commit 3580c3b
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions firebase/firestore.rules
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}

function isUserPermitted() {
let authDoc = get(/databases/$(database)/documents/auth/authorizedUsers);

return authDoc.data.emails.hasAll([request.auth.token.email]);
}
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}

match /forms/{formId} {
allow read: if isUserPermitted();

allow write: if isUserPermitted();
}

match /submissions/{submissionId} {
allow read: if isUserPermitted();

allow write: if isUserPermitted();
}

function isRequestUser(userId) {
return userId == request.auth.uid;
}

match /users/{userId} {
allow read: if isRequestUser(userId);
function isUserPermitted() {
let authDoc = get(/databases/$(database)/documents/auth/authorizedUsers);

return authDoc.data.emails.hasAll([request.auth.token.email]);
}

match /forms/{formId} {
allow read: if isUserPermitted();

allow write: if isRequestUser(userId);
}
allow write: if isUserPermitted();
}

match /submissions/{submissionId} {
allow read: if isUserPermitted();

allow write: if isUserPermitted();
}

function isRequestUser(userId) {
return userId == request.auth.uid;
}

match /users/{userId} {
allow read: if isRequestUser(userId);

allow write: if isRequestUser(userId);
}
}
}

0 comments on commit 3580c3b

Please sign in to comment.