Skip to content

Commit

Permalink
test: Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
lupas committed Dec 22, 2020
1 parent 43f48b6 commit aca0452
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules
rules/*
rulez.config.js
firebase.json
25 changes: 25 additions & 0 deletions test/firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {


////////////////////////////////////////////////////////
/////////// Local Functions:
////////////////////////////////////////////////////////
function isModeratorOrMores() {
return request.auth.token.role == 'moderator' ||
request.auth.token.role == 'admin' ||
request.auth.token.role == 'superadmin'
}

function isAdminOrMore() {
return request.auth.token.role == 'admin' ||
request.auth.token.role == 'superadmin'
}

function isSuperadmin() {
return request.auth.token.role == 'superadmin'
}

////////////////////////////////////////////////////////
/////////// Getters:
////////////////////////////////////////////////////////
function getCurrentUser() {
return get(/databases/$(database)/documents/users/$(authUserEmail())).data
}

////////////////////////////////////////////////////////
/////////// Allow all for admins:
Expand Down
6 changes: 6 additions & 0 deletions test/rulez.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
// Enables helper functions as specified below
helpers: true,
rules_version: '2',
custom_helpers_folder: "helpers",
}

0 comments on commit aca0452

Please sign in to comment.