firecms icon indicating copy to clipboard operation
firecms copied to clipboard

[Community] useFirestoreDelegate Firebase not initialised

Open LukasAnda opened this issue 10 months ago • 4 comments

Hey there, I wanted to add a basic user verification without using claims, but I am getting Firebase not initialised error.

This is my code:

const myAuthenticator: Authenticator<FirebaseUserWrapper> = useCallback(
    async ({ user, authController }) => {
      const idTokenResult = await user?.firebaseUser?.getIdTokenResult();
      const userIsAdmin = idTokenResult?.claims.admin;

      console.log("Allowing access to", user);

      const adminUser = await firestoreDelegate.fetchEntity({path:"cms/config/users", entityId:(user?.email ?? "")});

      return adminUser !== undefined;
    },
    []
  );

The issue is, the app works when I deploy it locally, but does not work when I deploy it to firebase hosting. What am I doing wrong?

LukasAnda avatar Mar 16 '25 11:03 LukasAnda

Hi @LukasAnda could you post the full error stacktrace?

fgatti675 avatar Mar 16 '25 11:03 fgatti675

Sure: Here is what I see in the console:

  | Mn | @ | index.es.js:4402
-- | -- | -- | --
  | kA | @ | react-dom.production.min.js:160
  | PV | @ | react-dom.production.min.js:289
  | kV | @ | react-dom.production.min.js:279
  | Ple | @ | react-dom.production.min.js:279
  | dw | @ | react-dom.production.min.js:279
  | wV | @ | react-dom.production.min.js:267
  | M | @ | scheduler.production.min.js:13
  | I | @ | scheduler.production.min.js:14

LukasAnda avatar Mar 16 '25 11:03 LukasAnda

Hi @LukasAnda , is still an issue or it has been solved?

If it's still unsolved, can you try to reference the full stack-trace of the error that you mentioned? Firebase not initialised error.

That should give us some clues.

marianmoldovan avatar May 02 '25 22:05 marianmoldovan

This has been resolved ^_^

LukasAnda avatar May 03 '25 06:05 LukasAnda