Created
October 19, 2016 14:20
-
-
Save DennisAlund/f80e35cd2be3b093e3ac52ed67b452aa to your computer and use it in GitHub Desktop.
An example of bolt file for the article: https://medium.com/evenbit/securing-your-firebase-app-part-2-33260a84dc78
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Message { | |
| message: String, | |
| author: FirebaseId, | |
| create() { isSignedIn() } | |
| read() { isSignedIn() } | |
| update() { isCurrentUser(this.author) } | |
| delete() { isCurrentUser(this.author) } | |
| } | |
| isCurrentUser(uid) { isSignedIn() && auth.uid === uid } | |
| isSignedIn() { auth !== null } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "rules": { | |
| "messages": { | |
| "$message_id": { | |
| ".validate": "newData.hasChildren(['message', 'author'])", | |
| "message": { | |
| ".validate": "newData.isString()" | |
| }, | |
| "author": { | |
| ".validate": "newData.isString()" | |
| }, | |
| "$other": { | |
| ".validate": "false" | |
| }, | |
| ".write": "data.val() == null && auth != null || data.val() != null && newData.val() != null && (auth != null && auth.uid == newData.child('author').val()) || data.val() != null && newData.val() == null && (auth != null && auth.uid == newData.child('author').val())", | |
| ".read": "auth != null" | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment