Skip to content

Fixes for delete-unused-accounts-cron example #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

appleby
Copy link
Contributor

@appleby appleby commented May 4, 2017

This pull request contains fixes needed to get the delete-unused-accounts-cron example working for me.

The CONTRIBUTING guide mentions running gulp build and tests before submitting a PR, but they don't seem to exist for this repo? Or I couldn't find them anyway, so I did manual testing following the setup instructions in the README file, namely:

  • Create a Firebase Project using the Firebase Developer Console
  • Download this sample e.g. git clone https://github.com/firebase/functions-samples
  • Enter the sample directory cd functions-samples/delete-unused-accounts-cron
  • Setup the sample with your project firebase use --add and follow the instructions.
  • Install node dependencies of your Functions cd functions; npm install; cd -
  • Add cron.key env var with firebase functions:config:set cron.key="YOUR-KEY"
  • Deploy your project using firebase deploy.

However, instead of using a third-party cron service to trigger the function, I just ran curl from my laptop like so:

 curl https://us-central1-<PROJECT-ID>.cloudfunctions.net/accountcleanup?key=<YOUR-KEY>

During testing, I also reduced the inactive users interval from 30 days to 10 minutes to make it easier to verify that inactive user accounts get deleted.

See individual commit messages for more info on each change.

appleby added 4 commits May 4, 2017 14:11
1) Fix a typo in the option name: header -> headers

This was causing the request for the service-account access token to
fail with error:

   StatusCodeError: 403 - "Missing required header: Metadata-Flavor\n"

2) Specify json: true in the request options

Without this option, the response was returned as a string and not
parsed as json. Consequently, resp.access_token was undefined.
The filter predicate was selecting users who had logged in during the
past month, whereas we want the opposite.
The user id property is called localId, not uid. The uid property is
undefined.
@nicolasgarnier
Copy link
Contributor

Awesome @appleby thanks for all the testing and the fixes :)

@nicolasgarnier nicolasgarnier merged commit 8e64a7b into firebase:master May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants