79289531

Date: 2024-12-17 22:40:12
Score: 1
Natty:
Report link

In 2024, there's actually an update!

  1. As far as I know, there is still now way to suppress deployed functions. This is only possible while testing when using the emulator, see https://firebase.google.com/docs/reference/emulator-suite/rules-unit-testing/rules-unit-testing.md#withfunctiontriggersdisabled.

BUT:

  1. Yes, it is now possible to to retrieve some information about the auth user that performed a write that led to the trigger function being run: https://firebase.google.com/docs/functions/firestore-events?gen=2nd#auth-context

Example from the docs that verifies the calling user:

import { onDocumentWrittenWithAuthContext } from "firebase-functions/v2/firestore"

  exports.syncUser = onDocumentWrittenWithAuthContext("users/{userId}", (event) => {
  // retrieve auth context from event
  const { authType, authId } = event;

  let verified = false;
  if (authType === "system") {
    // system-generated users are automatically verified
    verified = true;
  } else if (authType === "unknown" || authType === "unauthenticated") {
    // admin users from a specific domain are verified
    if (authId.endsWith("@example.com")) {
      verified = true;
    }
  }
}); 
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Fabio Bove