Last active
May 29, 2018 11:10
-
-
Save sgr-ksmt/b551ccda509817caa51776a083e75676 to your computer and use it in GitHub Desktop.
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
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'; | |
// } | |
} | |
} |
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
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