Skip to content

Commit

Permalink
Merge pull request #225 from LaurierHawkHacks/218-setup-local-emulato…
Browse files Browse the repository at this point in the history
…rs-for-local-development

218 setup local emulators for local development
  • Loading branch information
juancwu authored Apr 9, 2024
2 parents a651e8f + 61fde3f commit 3fbf564
Show file tree
Hide file tree
Showing 5 changed files with 3,538 additions and 86 deletions.
17 changes: 6 additions & 11 deletions config/firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ service cloud.firestore {
}

match /databases/{database}/documents {
// Default rule to deny read/write access
match /{document=**} {
allow read, write: if false;
}

// Allow read/write access to the user owns documents
// Allow read/write access if
// 1. document is new
Expand All @@ -29,11 +24,6 @@ service cloud.firestore {
allow write: if isAuthenticated() && isAdmin();
}

// Allow read/write access to the entire database for admin users
match /{document=**} {
allow read, write: if request.auth != null && request.auth.token.admin == true;
}

// Tickets Collection Rules
match /tickets/{ticketId} {
// Only grant read perms to owner/admin
Expand All @@ -46,7 +36,12 @@ service cloud.firestore {
match /applications/{applicationId} {
// Only grant read access if you are owner/admin
allow read: if isAuthenticated() && (isAdmin() || isOwner(resource.data.applicantId));
allow write: if isAuthenticated() && isAdmin();
allow write: if isAuthenticated();
}

// Default rule to deny read/write access
match /{document=**} {
allow read, write: if false;
}
}
}
18 changes: 9 additions & 9 deletions config/storage.rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ rules_version = '2';
// allow write: if firestore.get(
// /databases/(default)/documents/users/$(request.auth.uid)).data.isAdmin;
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
match /b/{bucket}/o {
match /resumes/{resumeId} {
// allow read if owner or admin
allow read: if request.auth != null && resource.metadata.owner == request.auth.uid || request.auth.token.admin == true;
allow write: if request.auth != null;
}

match /resumes/{resumeId} {
// allow read if owner or admin
allow read: if request.auth != null && resource.metadata.owner == request.auth.uid || request.auth.token.admin == true;
allow write: if request.auth != null;
match /{allPaths=**} {
allow read, write: if false;
}
}
}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "concurrently \"pnpm run vite\" \"pnpm run emulators\"",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
"preview": "vite preview",
"format": "prettier . --write",
"format:check": "prettier . --check",
"test": "vitest run --coverage",
"test:dev": "vitest"
"test:dev": "vitest",
"emulators": "firebase emulators:start --project hawkhacks-dashboard",
"setup": "firebase init emulators",
"firebase": "firebase",
"vite": "vite"
},
"dependencies": {
"@headlessui/react": "^1.7.18",
Expand Down Expand Up @@ -40,11 +44,13 @@
"@vitejs/plugin-react": "^4.0.3",
"@vitest/coverage-v8": "^0.34.6",
"autoprefixer": "^10.4.16",
"concurrently": "^8.2.2",
"eslint": "^8.45.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"firebase-tools": "^13.7.1",
"jsdom": "^22.1.0",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
Expand Down
Loading

0 comments on commit 3fbf564

Please sign in to comment.