1
votes

I want to add the ability to admin users in my Angular 7 project using firebase for user authentication.

My application is successfully using firebase authentication of users in my project.

Now I want to give admin users of my program the ability to list users, update users, add users, control user roles, etc. I do not want my users to need to access the firebase admin console.

My first test is just to list firebase users using the admin.auth().listUsers function. There is good documentation on how to do this using node.js but not the next step with angular.

My issue is that the variable "admin" needs to be defined.

When I use the node.js code of:

var admin = require('firebase-admin');

I get a whole bunch of errors like:

ERROR in ./node_modules/google-gax/build/src/operationsClient.js Module not found: Error: Can't resolve './operations_client_config' in '/Users/Stan/Sites/google/dallas/node_modules/google-gax/build/src' ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js Module not found: Error: Can't resolve 'child_process' in '/Users/Stan/Sites/google/dallas/node_modules/google-auth-library/build/src/auth' ERROR in ./node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js Module not found: Error: Can't resolve 'child_process' in '/Users/Stan/Sites/google/dallas/node_modules/google-gax/node_modules/google-auth-library/build/src/auth'

When i don't put in the above require line the only issue is that "admin" is not defined.

I assume that there is some small set-up issue I have missed, but would really appreciate any help past this.

1
firebase admin is NOT intended to be used client-side. You can create "admin" CRUD capabilities using firebase rules. There are examples of these types of rules/restrictiions in github.com/firebase/friendlypix-web as well as other projects. - Alexander Staroselsky

1 Answers

4
votes

The admin sdk is only available for nodejs. So you cannot use it on the front-end.

You can create a firebase cloud function for that. And deploy it in your project. Then you can call that function in your angular application.