Created
July 21, 2016 05:01
-
-
Save rohitsuratekar/e04ffa8426ccfcf7a7528935b355e92a to your computer and use it in GitHub Desktop.
FIrebase 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":{ | |
// Normal users will have access to only "users" | |
"users":{ | |
"$user_id":{ | |
// grants access to the owner of this user account | |
// whose uid must exactly match the key ($user_id) | |
".write":"$user_id === auth.uid", | |
".read":"$user_id === auth.uid" | |
} | |
}, | |
// Moderators will have "read" access to "mods". You can add individual moderator's UID in this node | |
"mods" :{ | |
".write":false, | |
".read":"root.child('mods').child(auth.uid).exists()" | |
}, | |
//Store user details with their email ID as node. | |
//For this create another node with email IDs stored in their respective UID | |
"usersWithEmail":{ | |
"$email_id": { | |
".write": "root.child('authEmails').child(auth.uid).val().replace('.', '_').replace('@', '_') == $email_id && auth !== null", | |
".read": "auth !== null" | |
} | |
}, | |
"authEmails":{ | |
"$user_id":{ | |
// grants access to the owner of this user account | |
// whose uid must exactly match the key ($user_id) | |
".write":"$user_id === auth.uid", | |
".read":"$user_id === auth.uid" | |
} | |
}, | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment