-1

I am debating whether or not I should launch my app using my test project on firebase. Its works fine the only thing is that there are 400 users in the athentication which I cant remove.

Question:

If I chose to launch my app with my current DB (which has like 400 test users) would I come across any sort of problem (of course I would delete any existing data in DB and storage)? And 2 is it easy to switch to a new project shortly after?

What I am currently testing:

    const deleteAllUsers = async (nextPageToken?) => {
    // List batch of users, 10 at a time.
    const listUsersResult = await admin.auth().listUsers(10, nextPageToken);
    listUsersResult.users.forEach(async userRecord => {
      await admin.auth().deleteUser(userRecord.uid);
      console.log('Successfully deleted user');
    });
    if (listUsersResult.pageToken) {
      // Wait to delete each set of users to abide by Firebase timeout
      setTimeout(() => deleteAllUsers(listUsersResult.pageToken), 2000);
    } else {
      console.log('no more users found');
    }
};
await deleteAllUsers();

2 Answers2

1

1- You can delete current test users one by one from console or as a whole using the terminal or admin sdk

2- It's easy to switch projects later on, but it's hard to transfer data (possible, but not a one click)

To edit user from terminal of your computer:

1- Install Firebase CLI

> npm install -g firebase-tools
> firebase login
> firebase init

2- export user accounts with filename extension to choose format .json or .csv

> firebase auth:export account_file_name.json

or

> firebase auth:export account_file_name.csv

3- edit the file (keep a copy just in case) then import it to Firebase

> firebase auth:import account_file_name.json

Note: I've only tried exporting the user accounts, I've never imported it back, so I don't know what you're facing. I suggest you look into keeping a back up if there are important things and only do it if you're confident. You can also create a new dummy project and play with it!

aldobaie
  • 1,387
  • 10
  • 15
  • "Using the terminal" do you mean on firebase or one local computer: could u give me some guidance on how to do that? –  Aug 24 '19 at 20:35
  • Using firebase's web console you can delete users from auth manually, it is also possible from the admin sdk – chrismclarke Aug 24 '19 at 21:07
1

If you are happy with your current system and only want to remove users, this is easy to do either through the firebase admin sdk, or web console.

Using the SDK

admin.auth().deleteUser(uid)
  .then(function() {
    console.log('Successfully deleted user');
  })
  .catch(function(error) {
    console.log('Error deleting user:', error);
  });

Full details available at the following link: https://firebase.google.com/docs/auth/admin/manage-users#delete_a_user

This is also discussed in Delete all users from firebase auth console

Using the web console delete firebase user from console

chrismclarke
  • 1,995
  • 10
  • 16