Is there an easy way to delete all registered users from firebase console? For example, I created a hundred users from my development environment, and now I want to delete a
As in updated answer, you can probably use firebase admin tools now, but if you don't want – here is a bit more solid javascript to remove users in the web:
var intervalId;
var clearFunction = function() {
var size = $('[aria-label="Delete account"]').size()
if (size == 0) {
console.log("interval cleared")
clearInterval(intervalId)
return
}
var index = Math.floor(Math.random() * size)
$('[aria-label="Delete account"]')[index].click();
setTimeout(function () {
$(".md-raised:contains(Delete)").click()
}, 1000);
};
intervalId = setInterval(clearFunction, 300)
Just run it in developer tools
Here is my bicycle:
Russian version
var intervalId;
var clearFunction = function() {
if ($('[aria-label="Удаление аккаунта"]').size() == 0) {
console.log("interval cleared")
clearInterval(intervalId)
return
}
$('[aria-label="Удаление аккаунта"]')[0].click();
setTimeout(function () {
$('[ng-click="controller.submit()"]').click()
}, 1000);
};
intervalId = setInterval(clearFunction, 3000)
French version,
var intervalId;
var clearFunction = function() {
if ($('[aria-label="Supprimer le compte"]').size() == 0) {
console.log("interval cleared")
clearInterval(intervalId)
return
}
$('[aria-label="Supprimer le compte"]')[0].click();
setTimeout(function () {
$(".md-raised:contains(Supprimer)").click()
}, 1000);
};
intervalId = setInterval(clearFunction, 3000)
PS: if you are not web developer and "Execute in tools developer" means nothing to you, here the procedure.
In the console tab, paste this code and press enter.
If the language matched with the code your paste, account will start to be deleted.
Because I'm pretty lazy at clicking buttons and elements in the UI, I set up a small client script:
$('[aria-label="Delete account"]').click()
setTimeout(function () {
$(".md-raised:contains(Delete)").click()
}, 1000);
You may need to run it multiple times, but it is much better than wasting the time clicking things on the screen manually.
This might be helpful to some. If you have access to the firebase user console - just save the page as an html and use the following to delete users with node. need to setup firebase-admin
let fs = require('fs'),
admin = require('firebase-admin'),
cheerio = require('cheerio');
// initialize firebase admin here
admin.initializeApp({
credential: admin.credential.cert('path/to/serviceAccountKey.json'),
databaseURL: 'https://<DATABASE_NAME>.firebaseio.com'
});
// use cheerio to load the html file you downloaded
$ = cheerio.load(fs.readFileSync('./yourfirebaseconsole.html'));
$('.a12n-user-uid .fb-table-cell-wrapper').each(function() {
admin.auth().deleteUser($(this).text());
}).then(() => {
console.log('successfully delete user');
}).catch((error) => {
console.log('error occurred ', error);
});
I would recommend doing a dry run of the html parsing logic once on the page using browser by just running this and confirming that only user ids are displayed in the result. In my case this returned all UIDs
$('.a12n-user-uid .fb-table-cell-wrapper').each(function() {
console.log($(this).text());
});