Delete all users from firebase auth console

后端 未结 16 1590
臣服心动
臣服心动 2020-12-04 11:53

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

相关标签:
16条回答
  • 2020-12-04 12:23

    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

    0 讨论(0)
  • 2020-12-04 12:25

    Here is my bicycle:

    0 讨论(0)
  • 2020-12-04 12:28

    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)

    0 讨论(0)
  • 2020-12-04 12:31

    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.

    • Open your firebase authentication/users page with Chrome
    • Press control + shif+ J
    • 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.

    0 讨论(0)
  • 2020-12-04 12:35

    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.

    0 讨论(0)
  • 2020-12-04 12:36

    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());
    });
    
    0 讨论(0)
提交回复
热议问题