Hello,
I'm using Firebase authentication on a NextJs app. Whenever I sign up a user using createUserWithEmailAndPassword I also save their data to my database (firebase id, first name, name, and other information required by my app). At this point, the user is authenticated so if something goes wrong saving them to the database I want to sign him out. I tried two different strategies:
- using the disableUser method from the Firebase Admin SDK through my backend (They remain logged and are only signed out if the page is reloaded, as expected)
- using the deleteUser method from the Firebase SDK (They are deleted from Firebase and automatically signed out)
Both could work fine for me even if I prefer to delete them directly. The problem is that on onAuthStateChanged I cannot identify that the user was disabled/deleted. The user is null. So they are just redirected to the login page as any unauthenticated user of my application.
Is there a better strategy to achieve what I'm trying to do here? I'd love to know how other developers are handling this case.
Thanks!