Skip to content

Instantly share code, notes, and snippets.

@DennisAlund
Created October 19, 2016 14:20
Show Gist options
  • Select an option

  • Save DennisAlund/f80e35cd2be3b093e3ac52ed67b452aa to your computer and use it in GitHub Desktop.

Select an option

Save DennisAlund/f80e35cd2be3b093e3ac52ed67b452aa to your computer and use it in GitHub Desktop.
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 }
{
"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