This is the runnable sample code from the blog post Patterns for security with Firebase Authentication: offload work to Cloud Functions. It discusses offloading work from a client app to Cloud Functions using an authentication trigger.
- Create a new Firebase project
- Enable email/password authentication
- Provision Cloud Firestore and apply the rules given in this gist
- Use the Firebase CLI to create a workspace for Functions using TypeScript
- Deploy the given HTML and JavaScript to Firebase Hosting (the CLI emulator will also work).
- Deploy the function code to Cloud Functions using the Firebase CLI
- Load up the page and create an account. See how it’s able to immediately respond to the new document being created by the deployed auth trigger.