I am using firebase-auth and firebase-document elements in Polymer. I am signed in with "google" as provider. My firebase database is like below:
firebase-app-id-location
[-]users
[-]user1.uid
[-]user2.uid
So i am planning to create new users as they sign up using "Google". Each of the node user1.uid will contain their own details. In order to keep everyones details private i set up the below security rules.
"rules": {
"users": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
".read": "auth !== null && auth.uid === $uid"
In order to test my code i have manually created a node under users using the firebase dashboard and everything is working fine. But NOW, How do user initiates the signup process? because the users/
node is only readable/writeable to the logged in user, how do I check if the user is already present under users/
and if not create a new new node users/user3.uid
.
In side firebase-document
polymer element i am setting up the location as
location = "firebase-app-location.com/users/user.uid"
. If the user is present then my app is working fine and fetching the data. But if the user is not present then i want to create a node under users/ and load some preset dummy data.
Any ideas? How to get this working.