This sample shows how to cleanup the user data when they delete their account.
See file functions/index.js for the user data cleanup code.
Deleting the user data is performed upon an account deletion on a functions.auth.user().onDelete trigger using the firebase-admin package.
The dependencies are listed in functions/package.json.
When a user signs-in we write some sample personal data of the following form:
/functions-project-12345
/users
$uid : "Some user data"
When the user deletes their account a Function will trigger and automatically delete the corresponding user data in the realtime database.
The function triggers on user account deletions.
This sample comes with a Function and web-based UI for testing the function. To configure it:
- Create a Firebase Project using the Firebase Console.
- Clone or download this repo and open the
user-data-cleanupdirectory. - You must have the Firebase CLI installed. If you don't have it install it with
npm install -g firebase-toolsand then configure it withfirebase login. - Configure the CLI locally by using
firebase use --addand select your project in the list. - Install dependencies locally by running:
cd functions; npm install; cd - - Deploy your project using
firebase deploy - Open the app using
firebase open hosting:site, this will open a browser. - Sign in using Google Sign-In and delete the account using the provided button. You can check at each step of the way if the data has been deleted using the Firebase console.