skip to Main Content

After searching for numerous hours all over the web and asking ChatGPT, I have found no solution.

I have a Firebase Project (Web App) and I am using Gen2 Javascript Node for Firebase Functions. I have enabled Firebase Auth with Identity Platform in my project.

I am ONLY using emulators currently.

The problem I’m having is that the beforeUserCreated event (blocking function) is not being called in my emulator.

All other functions work perfectly. Users get created (when they shouldn’t due to the blocking function) and there are no errors in the logs.

My index.js file looks like this:

import * as v2 from "firebase-functions/v2";

import {
    beforeUserCreated,
    beforeUserSignedIn,
  } from "firebase-functions/v2/identity";

export const helloworld = v2.https.onRequest((request, response) => {
    response.send("Hello from Firebase!");
});


export const beforeusercreated = beforeUserCreated({ region: 'europe-west1' }, (event) => {
    const user = event.data;
  // Only users of a specific domain can sign up.
    if (!user.email || !user.email.endsWith("@example.com")) {
        throw new HttpsError("invalid-argument", "Unauthorized email");
    }
  });

I also get this in the function logs in the emulator:

✔  functions[us-central1-beforeusercreated]: providers/cloud.auth/eventTypes/user.beforeCreate function initialized (http://127.0.0.1:5101/univus-9457e/us-central1/beforeusercreated).

Can someone please help me out here. Has anyone found a solution to this?

I’ve tried changing the function names, nothing changes. There are no errors, no documentation anywhere!

2

Answers


  1. I actually had the same issue and contacted firebase support regarding it. Apparently, they reached out and told me they were able to replicate the issue on their end in emulator environment and have raised the issue to their team for functions not working in emulator environment ,failing to trigger during user creation. Support did mention that I can still use them with my actual app and recommended me to test on it instead.

    Login or Signup to reply.
  2. Make sure you have enabled blocking functions in your firebase project. I think the emulator suite does a check make sure you have enabled the feature before allowing it to run.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search