1

I have been trying to set up a page using Angular, where an admin with requisite permissions can add users using Firebase 'username' and 'password' authentication.

I have been lurking around stackoverflow for answers. I have found : Firebase create user "manually" and this: Firebase kicks out current user

Going by the answers, I think they have achieved this by not using the Admin SDK and by bypassing the re-authentication that happens after a user is registered.

Problem is, I am a newbie and I am working in Angular. I was told to add the API keys and everything in the environment.ts and then add the Initialize method to the app.module.ts. How do I go about this special use case? The procedure I follow could be wrong altogether. I am trying to wrap my head around this. Any help or a link to any resource online would be greatly appreciated. Thanks.

user165242
  • 1,379
  • 2
  • 12
  • 18
  • 1
    https://firebase.google.com/docs/auth/admin/manage-users#create_a_user – camden_kid Sep 29 '17 at 12:35
  • Doesn't the admin SDK require node? I was hoping to have angular as front end and firebase as backend. Is there something that I am missing? – user165242 Sep 29 '17 at 12:56
  • 1
    You can use Angular and Firebase for front end and Firebase functions for backend - https://firebase.google.com/docs/functions/. you don't need a separate Node server. – camden_kid Sep 29 '17 at 13:09
  • Thanks. I was thinking of some solution of this kind: https://firebase.google.com/docs/web/setup#initialize_multiple_apps. I think this is the same solution implemented in https://stackoverflow.com/questions/37553362/firebase-create-user-manually. But how do I do this in Angular? – user165242 Sep 29 '17 at 15:09

1 Answers1

1

Well in the end it goes this way.

  • Keep the regular initilize.app method in your app.module.ts.

  • Initialize the App again as a separate service (or wherever) with a separate name, which would be something like initialize.app(config,"secondary"); - The "secondary" thing is important. Call it any name, I just added it as secondary. Add users with this initialization. config is your API key and other files you get from firebase.

  • Because of this "secondary" initialization there would not be any re-authentication of the user.

Phew. Thats like two days of work. lol.

user165242
  • 1,379
  • 2
  • 12
  • 18
  • That was the same thing that was being said in the links that I gave in the question earlier. But, https://github.com/angular/angularfire2/issues/761 helped me out as I was confused where to add the secondary initialization in angular, whether it is the app.module or elsewhere. – user165242 Oct 02 '17 at 10:24