netlify / gotrue

An SWT based API for managing users and issuing SWT tokens.
https://www.gotrueapi.org
MIT License
3.82k stars 283 forks source link

Support multiple function hooks per event #263

Closed vbrown608 closed 3 years ago

vbrown608 commented 3 years ago

- Summary Netlify supports automatically triggering Netlify Functions called identity-validate, identity-signup, andidentity-login when those events occur in Gotrue. We could also like to support background functions, eg identity-validate-background. That means there can be multiple functions that should be triggered for each event. This PR updates Gotrue to support a list of functions that should be triggered when each event occurs.

GoTrue currently gets function hooks in the following form:

"function_hooks" : {
  "signup": "identity-signup"
}

This PR additionally supports this form:

"function_hooks" : {
  "signup": ["identity-signup", "identity-signup-background"]
}

Reviewing this PR by commit may be helpful.

- Test plan Going to run some tests in staging tomorrow, will update here with details.

- Description for the changelog Support triggering multiple function hooks per event.

- A picture of a cute animal (not mandatory but encouraged) tiger

vbrown608 commented 3 years ago

I liked it better too, but it turns out ["identity-signup"] actually matches to []interface{}, not []string, and then it's necessary to make an additional assertion about every member of the list.