Created
August 25, 2015 17:25
Upvoting example for Firebase security rules
This file contains 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": { | |
".read": true, | |
"articles": { | |
"$article": { | |
"title": { | |
".write": "auth != null", | |
".validate": "newData.isString() && newData.val() != ''" | |
}, | |
"url": { | |
".write": "auth != null", | |
".validate": "newData.isString() && newData.val() != '' && newData.val().matches(/^http.*$/)" | |
}, | |
"votes": { | |
".write": "root.child('users').child(auth.uid).child('votes').child($article).val() != true" | |
}, | |
"user": { | |
".write": "auth != null" | |
} | |
} | |
}, | |
"users": { | |
"$user": { | |
".write": "auth != null && auth.uid === $user", | |
"votes": { | |
"$vote": { | |
".write": "!data.exists()" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Won't this mean a user can only vote once, but when they vote they can change votes t whatever they want?