1

I am doing a project with angular as the front end and nodejs as the backend.

The database and authentication mechanisms are managed by firebase cloud.

The problem is i am stuck with the authentication mechanism. It seems there are a lot of ways we can manage authentication using firebase.

I want my backend to deal with the authentication part, and i am using a email and password ecosystem for authentication.

But it seems that there is 2 npm packages one for angular firebase and another one for nodejs firebase-admin.

I am in a mess to determine what method to use and how to use it effectievly to manage the authentication flow here, due to overflow of resources.

There seems to be signInWithUserNameAndPassword in firebase and there seems to be signInWithCustomToken in the firebase-admin.

Can anyone show me the right path to go through?

I looked at this answer but i don't know why we need to pass the token back to client and then pass it to admin side again for verification?

The client side in my app is a web project. Is there any mistake on my understanding?

Thank you in advance

HexaCrop
  • 3,863
  • 2
  • 23
  • 50

2 Answers2

1

You will use signInWithUserNameAndPassword method. A token will be returned to you which you can store in localStorage which is security wise a bad idea but is okay for simple projects for practice. Alternatively, you can use angular-persistence or similar libraries to persist your state. Then, you can authenticate a user with whether his/her token is present in state or not.

Saeed Ahmad
  • 138
  • 3
  • 10
1

firebase-admin doesn't support any user authentication APIs. So you must do your authentication at the client-side using the firebase package, and the signInWithEmailAndPassword() API it provides: https://firebase.google.com/docs/auth/web/password-auth

Hiranya Jayathilaka
  • 7,180
  • 1
  • 23
  • 34