Skip to content

Instantly share code, notes, and snippets.

@ThadeuLuz
Created September 26, 2017 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThadeuLuz/367780442c6925e9d43c0114db781154 to your computer and use it in GitHub Desktop.
Save ThadeuLuz/367780442c6925e9d43c0114db781154 to your computer and use it in GitHub Desktop.
A better stack for your Firebase Rules - Bolt example
// Indicates if a user is logged in
imLoggedIn() {
auth != null
}
// Checks for the correc user id
myUidIs(uid) {
imLoggedIn() && auth.uid == uid
}
// Checks if user is the server
imServer() {
myUidIs('SERVER')
}
// User Profile type
type User {
displayName: String,
age: Number
}
// Adds server read access to all profiles at once (allows search)
path /users { read() { imServer() } }
// User rules for read and write
path /users/{userId} is User {
read() { myUidIs(userId) }
write() { myUidIs(userId) || imServer() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment