Skip to content

Commit 0b86d02

Browse files
authored
Merge pull request #170 from CreateThrive/feature/interface
Feature: Interface for database
2 parents b961153 + dd203a5 commit 0b86d02

File tree

20 files changed

+635
-104
lines changed

20 files changed

+635
-104
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
6464
- PWA ready thanks to CRA and Firebase
6565
- Multi-tenancy
6666
- Internationalization (English/Spanish)
67+
- Ability to choose between Firebase Realtime Database or Firestore
6768

6869
## Tech Stack
6970

@@ -88,6 +89,7 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
8889
- [Format.js](https://formatjs.io/) (★ 11.7k) libraries for internationalization (see [docs](https://formatjs.io/docs/basic-internationalization-principles)).
8990
- [date-fns](https://date-fns.org/) (★ 22.3k) date utility library (see [docs](https://date-fns.org/docs/Getting-Started)).
9091
- [cross-env](https://github.com/kentcdodds/cross-env) (★ 4.9k) run scripts that set and use environment variables across platforms (see [docs](https://www.npmjs.com/package/cross-env)).
92+
- [Inquirer](https://github.com/SBoudrias/Inquirer.js/) (★ 12.2k) A collection of common interactive command line user interfaces (see [docs](https://github.com/SBoudrias/Inquirer.js/#documentation)).
9193

9294
### Unit Testing
9395

firebase.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"predeploy": [
2424
"npm --prefix \"$RESOURCE_DIR\" run lint",
2525
"npm --prefix \"$RESOURCE_DIR\" run build"
26-
]
26+
],
27+
"source": "functions"
28+
},
29+
"firestore": {
30+
"rules": "firestore.rules",
31+
"indexes": "firestore.indexes.json"
2732
}
2833
}

firestore.indexes.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"indexes": [],
3+
"fieldOverrides": []
4+
}

firestore.rules

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
rules_version = '2';
2+
service cloud.firestore {
3+
match /databases/{database}/documents {
4+
5+
function isAuthenticated() {
6+
return request.auth != null && request.auth.token.email_verified == true;
7+
}
8+
9+
function isAdmin() {
10+
return request.auth.token.isAdmin == true;
11+
}
12+
13+
14+
match /users/{userId} {
15+
16+
function isIdentified() {
17+
return request.auth.uid == userId;
18+
}
19+
20+
allow read: if isAuthenticated() && (isAdmin() || isIdentified());
21+
22+
allow write: if isAuthenticated() && isAdmin();
23+
24+
allow update: if isAuthenticated() && (isAdmin() || isIdentified());
25+
26+
allow delete: if isAuthenticated() && isAdmin();
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)