Skip to content

Instantly share code, notes, and snippets.

@sgr-ksmt
Last active May 29, 2018 11:10
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 sgr-ksmt/b551ccda509817caa51776a083e75676 to your computer and use it in GitHub Desktop.
Save sgr-ksmt/b551ccda509817caa51776a083e75676 to your computer and use it in GitHub Desktop.
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
match /user/{userID} {
allow read: if isAuthenticated();
allow create: if true;
allow update: if request.writeFields.size() == 1;
}
// It will work on creating new user. 🤔
// match /user/{userID} {
// allow read: if isAuthenticated();
// allow create: if true;
// allow update: if userID == 'xxxx';
// }
}
}
Firestore.firestore().collection("user").document().setData(["name": "foo"]) { error in
if let error = error {
print("create user error: \(error)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment