Code Monkey home page Code Monkey logo

Comments (9)

Ehesp avatar Ehesp commented on July 25, 2024

Hey @DavidPrecopia

Not sure if it's a typo, however above you mention the config value is users while the structure is user - that will be the issue if it's not a typo.

from extensions.

DavidPrecopia avatar DavidPrecopia commented on July 25, 2024

It’s a typo - I just triple-checked the console and it’s users in both places.

from extensions.

Ehesp avatar Ehesp commented on July 25, 2024

Ok, the other thing which has caught users out in the past is trailing spaces in the path names (which are valid Collection paths). If you go onto the console, click "Reconfigure extension" and highlight the box, just make sure there is no additional spaces on the end.

from extensions.

DavidPrecopia avatar DavidPrecopia commented on July 25, 2024

Checked, no whitespace.

from extensions.

DavidPrecopia avatar DavidPrecopia commented on July 25, 2024

After playing around some more I found out that the function only deletes the user document if does not contain sub-collection(s) with documents. If the sub-collection(s) is empty, the function deletes the user document.

Additionally, if the user document contains fields and a sub-collection with documents, the fields are deleted, but the sub-collection is left untouched.

from extensions.

Ehesp avatar Ehesp commented on July 25, 2024

There is currently code waiting to go into prod which handles nested sub-document delete using firebase-tools. That being said, if a document has sub-collections at the moment, that shouldn't impact the actual document being deleted.

from extensions.

Ehesp avatar Ehesp commented on July 25, 2024

Hi @DavidPrecopia, could you run the following command on your machine:

firebase ext:list --project=<name> --json

Could you extract the item for your deployed extension and ensure any sensitive data is removed. I'm not seeing this issue myself so understanding the exact instance config would be very helpful. Thanks!

from extensions.

DavidPrecopia avatar DavidPrecopia commented on July 25, 2024

Here you go @Ehesp,

{
  "status": "success",
  "result": {
    "instances": [
      {
        "name": "projects/lists-debug/instances/delete-user-data",
        "createTime": "2019-11-03T21:09:45.767898Z",
        "updateTime": "2019-11-05T18:43:49.548008Z",
        "state": "ACTIVE",
        "config": {
          "name": "projects/lists-debug/instances/delete-user-data/configurations/394e8b1f-a7b4-41e6-b6bc-cac55bffd1d9",
          "createTime": "2019-11-05T18:42:06.159691Z",
          "source": {
            "name": "projects/firebasemods/sources/8deccc46-5537-4631-929a-d087c961cee5",
            "packageUri": "http://storage.googleapis.com/bkend-firebase-tools/delete-user-data.1568839870.zip",
            "hash": "be5c4ff2ed9da9993e01884918d6f5c87dd65765c06d81e0184ae082cf91b41b",
            "spec": {
              "specVersion": "v1beta",
              "name": "delete-user-data",
              "version": "0.1.1",
              "description": "Deletes data keyed on a userId from Cloud Firestore, Realtime Database, and/or Cloud Storage when a user deletes their account.",
              "roles": [
                {
                  "role": "datastore.user",
                  "reason": "Allows the extension to delete (user) data from Cloud Firestore."
                },
                {
                  "role": "firebasedatabase.admin",
                  "reason": "Allows the extension to delete (user) data from Realtime Database."
                },
                {
                  "role": "storage.admin",
                  "reason": "Allows the extension to delete (user) data from Cloud Storage."
                }
              ],
              "resources": [
                {
                  "name": "clearData",
                  "type": "firebaseextensions.v1beta.function",
                  "propertiesYaml": "eventTrigger:\n  eventType: providers/firebase.auth/eventTypes/user.delete\n  resource: projects/${PROJECT_ID}\nlocation: ${LOCATION}\nsourceDirectory: .\n",
                  "description": "Listens for user accounts to be deleted from your project's authenticated users, then removes any associated user data (based on Firebase Authentication's User ID) from Realtime Database, Cloud Firestore, and/or Cloud Storage.",
                  "deletionPolicy": "DELETE"
                }
              ],
              "author": {
                "authorName": "Firebase",
                "url": "https://firebase.google.com"
              },
              "contributors": [
                {
                  "authorName": "Lauren Long",
                  "url": "https://github.com/laurenzlong"
                },
                {
                  "authorName": "Chris Bianca",
                  "email": "[email protected]",
                  "url": "https://github.com/chrisbianca"
                }
              ],
              "license": "Apache-2.0",
              "releaseNotesUrl": "https://github.com/firebase/extensions/commits/master",
              "sourceUrl": "https://github.com/firebase/extensions/tree/master/delete-user-data",
              "params": [
                {
                  "param": "LOCATION",
                  "label": "Deployment location",
                  "type": "SELECT",
                  "description": "Where should the extension be deployed? You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations#selecting_regions_for_firestore_and_storage).",
                  "required": true,
                  "options": [
                    {
                      "value": "us-central1",
                      "label": "Iowa (us-central1)"
                    },
                    {
                      "value": "us-east1",
                      "label": "South Carolina (us-east1)"
                    },
                    {
                      "value": "us-east4",
                      "label": "Northern Virginia (us-east4)"
                    },
                    {
                      "value": "europe-west1",
                      "label": "Belgium (europe-west1)"
                    },
                    {
                      "value": "europe-west2",
                      "label": "London (europe-west2)"
                    },
                    {
                      "value": "asia-east2",
                      "label": "Hong Kong (asia-east2)"
                    },
                    {
                      "value": "asia-northeast1",
                      "label": "Tokyo (asia-northeast1)"
                    }
                  ],
                  "default": "us-central1"
                },
                {
                  "param": "FIRESTORE_PATHS",
                  "label": "Cloud Firestore paths",
                  "type": "STRING",
                  "description": "Which paths in your Cloud Firestore instance contain user data? Leave empty if you don't use Cloud Firestore.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`.\nFor example, if you have the collections `users` and `admins`, and each collection has documents with User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.",
                  "example": "users/{UID},admins/{UID}"
                },
                {
                  "param": "RTDB_PATHS",
                  "label": "Realtime Database paths",
                  "type": "STRING",
                  "description": "Which paths in your Realtime Database instance contain user data? Leave empty if you don't use Realtime Database.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`.\nFor example: `users/{UID},admins/{UID}`.",
                  "example": "users/{UID},admins/{UID}"
                },
                {
                  "param": "STORAGE_PATHS",
                  "label": "Cloud Storage paths",
                  "type": "STRING",
                  "description": "Where in Google Cloud Storage do you store user data? Leave empty if you don't use Cloud Storage.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. You can use `{DEFAULT}` to represent your default bucket.\nFor example, if you are using your default bucket, and the bucket has files with the naming scheme `{UID}-pic.png`, then you can enter `{DEFAULT}/{UID}-pic.png`. If you also have files in another bucket called `my-awesome-app-logs`, and that bucket has files with the naming scheme `{UID}-logs.txt`, then you can enter `{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt`.",
                  "example": "{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt"
                }
              ],
              "preinstallContent": "Use this extension to automatically delete a user's data if the user is deleted from your authenticated users.\n\nYou can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's UserId.\n\n**Note:** To use this extension, you need to manage your users with Firebase Authentication.\n\nThis extension is useful in respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.\n\n#### Additional setup\n\nDepending on where you'd like to delete user data from, make sure that you've set up [Cloud Firestore](https://firebase.google.com/docs/firestore), [Realtime Database](https://firebase.google.com/docs/database), or [Cloud Storage](https://firebase.google.com/docs/storage) in your Firebase project before installing this extension.\n\nAlso, make sure that you've set up [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.\n\n#### Billing\n\nThis extension uses other Firebase or Google Cloud Platform services which may have associated charges:\n\n- Cloud Firestore\n- Firebase Realtime Database\n- Cloud Storage\n- Cloud Functions\n\nWhen you use Firebase Extensions, you're only charged for the underlying resources that you use. A paid-tier billing plan is only required if the extension uses a service that requires a paid-tier plan, for example calling to a Google Cloud Platform API or making outbound network requests to non-Google services. All Firebase services offer a free tier of usage. [Learn more about Firebase billing.](https://firebase.google.com/pricing)\n",
              "postinstallContent": "### See it in action\n\nYou can test out this extension right away:\n\n1.  Go to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users).\n\n1.  Click **Add User** to add a test user.\n\n1.  Copy the test user's UID to your clipboard.\n\n1.  Create a new Cloud Firestore document, a new Realtime Database entry, or upload a new file to Storage - incorporating the user's UID into the path according to the schema that you configured.\n\n1.  Go back to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users), then delete the test user.\n\n1.  In a few seconds, the new data you added above will be deleted from Cloud Firestore, Realtime Database, and/or Storage (depending on what you configured).\n\n### Using the extension\n\nWhen a user's account is deleted from your project's authenticated users, this extension automatically deletes their data from Cloud Firestore, Realtime Database, and/or Cloud Storage.\n\n* Cloud Firestore path(s): `${param:FIRESTORE_PATHS}`\n* Realtime Database path(s): `${param:RTDB_PATHS}`\n* Cloud Storage path(s): `${param:STORAGE_PATHS}`\n\nYou can delete a user directly in your [Authentication dashboard]((https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users)) or by using one of the Firebase Authentication SDKs. Learn more in the [Authentication documentation](https://firebase.google.com/docs/auth).\n\n### Monitoring\n\nAs a best practice, you can [monitor the activity](https://firebase.google.com/docs/extensions/manage-installed-extensions#monitor) of your installed extension, including checks on its health, usage, and logs.\n",
              "readmeContent": "# delete-user-data\n\n**VERSION**: 0.1.1\n\n**DESCRIPTION**: Deletes data keyed on a userId from Cloud Firestore, Realtime Database, and/or Cloud Storage when a user deletes their account.\n\n\n\n**CONFIGURATION PARAMETERS:**\n\n* Deployment location: Where should the extension be deployed? You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations#selecting_regions_for_firestore_and_storage).\n\n* Cloud Firestore paths: Which paths in your Cloud Firestore instance contain user data? Leave empty if you don't use Cloud Firestore.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`.\nFor example, if you have the collections `users` and `admins`, and each collection has documents with User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.\n\n* Realtime Database paths: Which paths in your Realtime Database instance contain user data? Leave empty if you don't use Realtime Database.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`.\nFor example: `users/{UID},admins/{UID}`.\n\n* Cloud Storage paths: Where in Google Cloud Storage do you store user data? Leave empty if you don't use Cloud Storage.\nEnter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. You can use `{DEFAULT}` to represent your default bucket.\nFor example, if you are using your default bucket, and the bucket has files with the naming scheme `{UID}-pic.png`, then you can enter `{DEFAULT}/{UID}-pic.png`. If you also have files in another bucket called `my-awesome-app-logs`, and that bucket has files with the naming scheme `{UID}-logs.txt`, then you can enter `{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt`.\n\n\n\n**CLOUD FUNCTIONS CREATED:**\n\n* clearData (providers/firebase.auth/eventTypes/user.delete)\n\n\n\n**DETAILS**: Use this extension to automatically delete a user's data if the user is deleted from your authenticated users.\n\nYou can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's UserId.\n\n**Note:** To use this extension, you need to manage your users with Firebase Authentication.\n\nThis extension is useful in respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.\n\n#### Additional setup\n\nDepending on where you'd like to delete user data from, make sure that you've set up [Cloud Firestore](https://firebase.google.com/docs/firestore), [Realtime Database](https://firebase.google.com/docs/database), or [Cloud Storage](https://firebase.google.com/docs/storage) in your Firebase project before installing this extension.\n\nAlso, make sure that you've set up [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.\n\n#### Billing\n\nThis extension uses other Firebase or Google Cloud Platform services which may have associated charges:\n\n- Cloud Firestore\n- Firebase Realtime Database\n- Cloud Storage\n- Cloud Functions\n\nWhen you use Firebase Extensions, you're only charged for the underlying resources that you use. A paid-tier billing plan is only required if the extension uses a service that requires a paid-tier plan, for example calling to a Google Cloud Platform API or making outbound network requests to non-Google services. All Firebase services offer a free tier of usage. [Learn more about Firebase billing.](https://firebase.google.com/pricing)\n\n\n\n**ACCESS REQUIRED**:\n\n\n\nThis extension will operate with the following project IAM roles:\n\n* datastore.user (Reason: Allows the extension to delete (user) data from Cloud Firestore.)\n\n* firebasedatabase.admin (Reason: Allows the extension to delete (user) data from Realtime Database.)\n\n* storage.admin (Reason: Allows the extension to delete (user) data from Cloud Storage.)\n",
              "displayName": "Delete User Data"
            },
            "fetchTime": "2019-09-18T20:51:29.052758576Z",
            "lastOperationName": "projects/firebasemods/operations/f4893ccb-b57f-4a53-9df1-4b94345df1f8"
          },
          "params": {
            "LOCATION": "us-central1",
            "FIRESTORE_PATHS": "users/{UID}"
          },
          "populatedPostinstallContent": "### See it in action\n\nYou can test out this extension right away:\n\n1.  Go to your [Authentication dashboard](https://console.firebase.google.com/project/lists-debug/authentication/users).\n\n1.  Click **Add User** to add a test user.\n\n1.  Copy the test user's UID to your clipboard.\n\n1.  Create a new Cloud Firestore document, a new Realtime Database entry, or upload a new file to Storage - incorporating the user's UID into the path according to the schema that you configured.\n\n1.  Go back to your [Authentication dashboard](https://console.firebase.google.com/project/lists-debug/authentication/users), then delete the test user.\n\n1.  In a few seconds, the new data you added above will be deleted from Cloud Firestore, Realtime Database, and/or Storage (depending on what you configured).\n\n### Using the extension\n\nWhen a user's account is deleted from your project's authenticated users, this extension automatically deletes their data from Cloud Firestore, Realtime Database, and/or Cloud Storage.\n\n* Cloud Firestore path(s): `/users/{UID}`\n* Realtime Database path(s): `{unspecified parameter}`\n* Cloud Storage path(s): `{unspecified parameter}`\n\nYou can delete a user directly in your [Authentication dashboard]((https://console.firebase.google.com/project/lists-debug/authentication/users)) or by using one of the Firebase Authentication SDKs. Learn more in the [Authentication documentation](https://firebase.google.com/docs/auth).\n\n### Monitoring\n\nAs a best practice, you can [monitor the activity](https://firebase.google.com/docs/extensions/manage-installed-extensions#monitor) of your installed extension, including checks on its health, usage, and logs.\n"
        },
        "lastOperationName": "projects/lists-debug/operations/2ec120fc-85d5-4797-8909-5dec5746a13d",
        "serviceAccountEmail": "REDACTED"
      }
    ]
  }
}

from extensions.

DavidPrecopia avatar DavidPrecopia commented on July 25, 2024

Fixed as of v0.1.2.

from extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.