Save Item under Firebase

I want to save some information under the Firebase Database and then be able to retrieve it later. For example I want to save the name of a user under their email after they register, so:

APP NAME
-email
-full name
-email2
-fullname2

Instead, this saves the information for all users on firebase.

Read this:

and apply your firebase rules as required

Would it be this set of code?

data
{
"rules": {
"": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}

This part of the data storage needs this structure in Firebase:

The spouse is not mandatory. I added it for fun.
Notice the indentation, where tag/value pairs hang off unique keys.

1 Like

The above will only allow a user to read and write to their own area. No other users can read their data

Note: I am assuming you are using firebase authentication - email and password (@ABG)

1 Like

I want it to be able to read others users data, but not modify it, So:

"rules": {
"": {
"$uid": {
".read": true,
// or ".read": "auth.uid != null" for only authenticated users
".write": "auth.uid == $uid"
}
}
}
}

Yes, something like this. I assume that you can change spouse to other values and add some more values if i wanted to later.

Yes, that is the beauty of Firebase and CloudDB, and a well designed tag/value tree.

1 Like

Not sure why, but it's still saving the info for all users

Confirm your users are signing up with firebase authentication please

Have you changed <Project Bucket> to your projectBucket ?

I use firebase authentication but my project bucket is just my app name

Please show example data saved in the firebase console for at least two authenticated users, with those rules



image

According to your database contents, you failed to create new branches for each new user.

To begin with, your security rules should be set like this:

{
 "rules": {
    "$uid": {
      ".read":  "$uid === auth.uid",
      ".write": "$uid === auth.uid"
    }
 }
}
1 Like

Yes, I’m troubleshooting that now

I used the code you provided in the Realtime database rules and it's still not working, still saving data for all users. Could it possibly be my blocks or the way I'm storing it? Because I'm simply just using the call FirebaseDB1 StoreValue and enter a tag that I want the thing I'm storing to go along with it, and when I want I retrieve it using the call FirebaseDB1 get value

You cannot use "just" the firebase component with authenticated users. You either need to use an extension, or use the web component with the RESTful api.

I'll point you back to my web component guide - read everything to understand, then apply

I read it and I applied the codes from the website into the rules but it's still not working, but for the realtime database JSON codes

Show your relevant blocks, your firebase rules and your firebase data structure from the console