这是indexloc提供的服务,不要输入任何密码
Skip to content

Create Firestore Trigger Function to Set User's Name from Firebase Auth DisplayName #404

@DennisAlund

Description

@DennisAlund

Description:

This issue aims to create a Firebase Cloud Function that triggers on the creation of a document in the tanam-users/{docId} collection. When a new user document is created, the function should set the user's name attribute in the Firestore document to the displayName from the Firebase Auth user object.

Objectives:

  1. Create onDocumentCreated Trigger:

    • Implement a Firebase Cloud Function that triggers when a new document is created in the tanam-users/{docId} collection.
  2. Fetch DisplayName from Firebase Auth:

  3. Update Firestore Document:

    • Set the name attribute in the Firestore document to the fetched displayName.

Acceptance Criteria:

  • A Firebase Cloud Function is created that triggers on document creation in the tanam-users/{docId} collection.
  • The function fetches the displayName from the Firebase Auth user object using the document ID as the UID.
  • The function updates the name attribute in the Firestore document with the fetched displayName.
  • Ensure proper error handling in case the displayName is not available or the user does not exist in Firebase Auth.

Notes:

  • Verify that the function works correctly by creating new user documents and checking that the name attribute is correctly set from the Firebase Auth displayName.
  • Ensure that the function has appropriate permissions to read from Firebase Auth and write to Firestore.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions