Search code examples
node.jsfirebase-realtime-databasefirebase-authenticationgoogle-cloud-functionsfirebase-admin

Google Cloud Function mistakenly deleted all user's record can i recover them?


i am using flutter for development and Firebase for auth and database and realtime database for storing strings and etc. I wrote a firebase function as followed:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.deleteAccount = functions.database.ref('users/{user_id}').onDelete((snapshot, context) => {
console.log(snapshot.key);

admin.auth().deleteUser(snapshot.key)
.then(function() {
    console.log("Successfully deleted user");
    return true;
})
.catch(function(error) {
    console.log("Error deleting user:", error);
});

return true;

});

Now what i did is i was editing the realtime database manually i exported all data and then deleted all data manually from realtime database. now as i wrote in the function to remove auth data according to the uid which was deleted. and guess what it deleted all users from authentication tab. Anyway to recover all auth data?


Solution

  • Once you delete a user in Firebase Auth, there is no way to revert or undo that operation. It is permanent.