Last active
October 24, 2018 08:52
-
-
Save nikitakarpenkov/dc98c203bb963aff9919a2ad657d6cf2 to your computer and use it in GitHub Desktop.
Script to delete all firebase users using firebase admin SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
function deleteAllUsers(nextPageToken) { | |
admin.auth().listUsers(10, nextPageToken) | |
.then(function(listUsersResult) { | |
listUsersResult.users.forEach(function(userRecord) { | |
admin.auth().deleteUser(userRecord.uid).then(() => { | |
console.log(`deleted ${userRecord.uid}`); | |
}); | |
}); | |
if (listUsersResult.pageToken) { | |
setTimeout(() => { | |
deleteAllUsers(listUsersResult.pageToken) | |
}, 1000); | |
} | |
}) | |
.catch(function(error) { | |
console.log(error); | |
}); | |
} | |
deleteAllUsers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment