Block to create DocumentReference by specifying Collection and ID in Firestore extension

hi I’m developing an Android application (preferring Kotlin/Java) and using a block development environment that integrates a specific Firebase Cloud Firestore extension.
My goal is to store user data in the Firestore Users collection. It’s crucial that the document ID for each user matches their UID (User ID) obtained from Firebase Authentication, as my Firestore security rules require userId == request.auth.uid . I tried using the Idriss and Jarlisson extension. Can you tell me which blocks I should use for this purpose? Thanks.

To achieve this you need to use the UID from Firebase Authentication as the document ID when writing to Firestore. This way, your Firestore rules userId == request.auth.uid will work correctly.

:wrench: Steps with blocks

  1. Get the UID

    • After the user signs in with Firebase Authentication, use the block FirebaseAuth.CurrentUserGet Id (or whichever block your extension provides to fetch the UID).
    • Store this in a variable, e.g. global userUID.
  2. Create a dictionary with user data

    • Use the make a dictionary block for fields like,

      "name" → NameTextBox.Text
      "email" → EmailTextBox.Text
      "phone" → PhoneTextBox.Text
      

      (you can add more fields as needed).

  3. Write to Firestore

    • Use the Firestore extension block Set Document (or Store Document depending on your extension).
    • Collection = "Users"
    • Document ID = global userUID
    • Data = dictionary you just made.

when FirebaseAuth.OnSignInSuccess do
   set global userUID to FirebaseAuth.CurrentUserID

   set userDict to make a dictionary
       "name" → NameTextBox.Text
       "email" → EmailTextBox.Text
       "phone" → PhoneTextBox.Text

   call Firestore.SetDocument
       collection = "Users"
       document = global userUID
       data = userDict

This ensures,

  • Each user’s data goes to /Users/{uid} in Firestore.
  • Your security rules will allow access only to their own document, since request.auth.uid matches the document ID.

Since i don’t have that extension am not able to provide blocks

:green_heart:

thnx i try

if you dont use extension where you take this block? call Firestore.SetDocument , i dont have in basic kodular

That’s why i said

Do you have the extansion?

It must contain it by default then add

i dont have default that block :sad_but_relieved_face:

I asked you here

3b50b3ded77ab6b3732c37ce652b39550ce082da

i dont have that block