Issue
I am developing an app where if a user deletes his account, other of his items get deleted as well but, firebase only allows the delete to happen 10 times. How do I overcome this? The deleting only happens at this.MyReviewsarray.foreach and this.myFavourites. thank you
this.mFirestore.collection("Users").doc(success.user.uid).delete().then((res) => {
this.mAuth.auth.currentUser.delete().then((res) => {
console.log(res)
this.myReviewArray.forEach(element => {
this.mFirestore.collection('Reviews').doc(element.id).delete();
});
this.myFavouritesArray.forEach(elements => {
this.mFirestore.collection("Favourites").doc(elements.id).delete();
})
this.toastController.create({
message: "Account Successfully Deleted",
duration: 2000
}).then(alert => alert.present());
this.router.navigateByUrl('/login')
}).catch((err) => {})
})
Solution
Your code should delete the user's data before deleting the user account itself. The user account should be the very last thing to delete, so that the user stays authenticated for all of the other delete operations.
Your code should also pay attention to the promises returned by all the calls to delete(), and only delete the user account after all those other promises are fully resolved. Right now, your code is fully ignoring all those promises.
Answered By - Doug Stevenson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.