Home > Back-end >  Sending stored data in Firebase directly with authentication without a second request
Sending stored data in Firebase directly with authentication without a second request

Time:09-16

I have a website which uses Firebase for user authentication and storing user data (SPA with JSON web token). The user data can be fetched as soon as the user is authenticated.

In the moment this works as follows:

  1. Client enters auth data
  2. Firebase confirms authentication
  3. client requests stored user data
  4. Firebase searches user data in database
  5. data is sent to user

What I want is the following:

  1. Client enters auth data
  2. Firebase authenticates user and searches directly for user data in database
  3. authentication is confirmed and data is sent to user.

In other words: In the first solution the way from the client to Firebase has to be made twice while in the second solution it only has to be made once (sending user data directly after authentication), such being faster.

Question: Is this possible?

CodePudding user response:

Firebase authenticates user and searches directly for user data in database

There is no connection between Firebase Authentication and a user-accessible database, so there is no way to do this in a single step without application-specific code.

What you can do is implement this process in a Cloud Function, so that it appears as a single step to the client-side application code. But in the server-side Cloud Functions code, it'll still be a two-step process with calls to two APIs.

  • Related