Deleting user profile from firestore database along with Firebase Auth

Hello Folks!

I am trying and searching for long time to figure out how to delete the user data that was stored while creating user profile along with firebase authentications. I am able to delete the user authentication data(user auth credentials) but its quite difficult to remove the same signed-in user data stored in firestore database on the same time.

I am using Firebase REST API to authenticate and delete user authentication. Soon after sign-up flow function, use a create record flow function to create user record(like name, email, idToken, UID…) with support of pageVars object with properties. Everything goes fine, I can Sign-up the user at the same time the records of the user also created a collection on firebase with auto document ID.

My concern here is the “Document ID” that was generated randomly by firestore while create record flow trigger after the user sign-up. I cannot retrieve the same document of the signed-in user from the firestore collection to delete the data associated with the same user while deleting user account.

Go through many AppGyver Forum post and videos to figure out my issue, but couldn’t found any that can solve my issue. Any tutorial or forum link that solve my issue welcome here…

Thanks

Try saving user documents In Firestore with the UId you get from the Auth as a custom id… That way the Auth and the user details will have the same ID.so when you retrieve and delete, you gonna do it where document ID = UID from Auth. I hope it helps

Thanks @F_ORTELL

I get to know from reading the forum that’s how it works… but my I coudn’t apply that in my app. I tried many ways(post, patch inside my best knowledge) using HTTP request but all fails. Can you please elaborate some more details. Appreciate your response.

In my project, I use firebase authentication to authenticate users only and store their details in Firestore… Are you doing the same?

I am also using firebase auth for user authentication using firebase REST API. @F_ORTELL

OK, users in firebase Auth have unique Id’s, so in Firestore, you can create Users collection and save documents in that collection with the ID you get from firebase Auth…
There’s a flow function that let you get the UId after the user logs in.um on mobile right now, so I can’t access composer to show you.
But basically you want user details document in Firestore to have same ID as the Auth

Really this is what I am looking for. User sign up is working together with creating user record in firestore database collection. But I cant make the document ID of the user information same as the UID

See the red marked in screenshot bellow

You want it to be something like ths

Ohh exactly like that @F_ORTELL

Sorry for multiple reply here. I found one in forum from @Dimos_Vamvourellis post here Firebase database implementation - #3 by Dimos_Vamvourellis explaining the same. But here in update record the ID makes me confusing again that how can I get the same signed-in user document ID from the collection.

OK. What you can do for now is to get the flow function that let’s you get firebase user details from the market, jus type firebase on the flow function market, you’ll see it. Then use that function to get the UId and store it as an app variable. Then use that ID as a custom id for your Firestore document.

Use the link below, it will show you how to post and patch with a custom id

@F_ORTELL I don’t know what is going wrong with me here…I am tired of running behind this.

Can you figure out the issue from the screenshot

Set request body as a formula and as :

{

“fields”: {

         "firstname": {"stringValue": "hello"} ,
         "lastname": {"stringValue": "world"} 

      }  

}

Populate the fields that what you need

Sorry for the detailed query, I am new to this @F_ORTELL

In my request body, “fields” replaced by my firestore database collection name and inside the “fields”, properties that matches the schema of the database collection, am I right?
I guess you look into my flow functions and all are correct except your point above…

Um new to Ths too, um jus trying my best … I struggled to get it working, but once you’re done with Ths, it gets better :sweat_smile:.

You need to generate the request body manually try to match the schema…You’ll get it working

Still the same… @F_ORTELL Manually set the request body in two different ways… Screenchot bellow

Sign-up user working fine but no record is creating on my data base. Is there any mistake in flow function or request body.

Also tried this format request body bellow… still the same.

{userInfo:{"userName": pageVars.userInfo.userName , "userEmail": pageVars.userInfo.userEmail , "userPassword": pageVars.userInfo.userPassword , "useridToken": pageVars.userInfo.useridToken , "uselocalId": pageVars.userInfo.userlocalId}}

Please please help me to get out of this..

Use the url below in your http request and put your firebase info, change projectname and collection name…in Ths case is (Myappgyverproject and Users)

“https://firestore.googleapis.com/v1/projects/MyappgyverProject/databases/(default)/documents/Users/”+appVars.uid

Set method to patch.

Leave header as it is.

Request body… The body structure is like Ths :

{

“fields”: {

             "firstname": {"stringValue": "hello"} ,
             "lastname": {"stringValue": "world"}
                } 

}

Try sending the above body to firebase,if you manage, you can create you own

Fields is a key word… So yours has to be something like ths ::


{

“fields”: {


             "userName": {"stringValue": "hello"} ,
             "userEmail": {"stringValue": "world"}, 
             "AddMore" :{"stringValue" :"variable"} 

           }  

}

I hope it helps

I made exactly what you say in your post above… still the record is not creating while sign up with new email… Sign-up flow works then send verification mail also user added in firebase authentication with UID… all set. But the user record is not creating on data base now.

I think biding each field “stringValues” with my pageVars properties maakes problem here. What do you say… any other suggestions?

I took the appVars UID’s value binding screenshot above to make sure you that it is correct.

Before following your instructions, I tried using create record flow function with support of pageVars object with properties… it create record on firebase with random Document ID.

Appreciate your support @F_ORTELL

I don’t get why yours is not working…

I did mine like ths.

1, I enabled firebase Auth on my appgyver project.

2, I then used a http request to sign up a user with email and password

3, now, when the user login,I use getcurrentuser function to get UId, then I redirect the user to account page to fill up user details.(username, etc)

4, when the user finish, I save the details in Firestore users and UId as the custom ID using http request.

… Are you able to create records in firestore using HTTP request function?

Try sending hard coded values to Firestore, if it works then you can try adding variables