You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create hook for account creation that adds example screener #338
Create an authenticated /api/account-hooks endpoint that takes the following request type. Sending an auth bearer token should already include the account's user ID.
typeAccountHookRequest={action: "add example screener"|"some other action"}
Call the endpoint after successful account creation.
The endpoint can then call addExampleScreenerToAccount() and will act like a normal API request.
I think there are two places we can call the endpoint:
In the frontend context/AuthContext.jsx and modify register(email, password) by using createUserWithEmailAndPassword(auth, email, password).then(someHookFunction).
In the Firebase Auth by adding a Firebase Cloud Function. This would store the hook trigger and function in a separate file and would need Firebase to configure it.
I'm leaning towards putting the API request in the frontend so the hook is stored in the same location as the account creation code and not tied to Firebase.
Advantage: Account creation hook code is next to account registration code. Deployment is not linked to Firebase Cloud Function. If we move away from Firebase Auth, we don't have to worry about porting over that piece of code
Disadvantage: Errors are not tied to new Firebase account registrations. If there is an error in the hook, the account is still created without the hook's results.
This is amazing work! Really appreciate the thought here. I'm not sure about the place to trigger this, specifically the Google login might not distinguish between creating an account and logging in. Also I feel like account creation side effects does feel like a very backend responsibility. But think triggering it here for now would be a good start and we could easily develop a backend function to call the endpoint triggered by firebase auth in the future after further discussion.
I think you should definilty keep going in this direction. Also one small thing. I think it would be good to save the action types as an enum on the backend. We have other enums in the repo that can provide a good example.
Activity
joshwanf commentedon Mar 10, 2026
@prestoncabe @Michael-Dratch @Justin-MacIntosh
Here is my initial commit 36926cf
Create an authenticated
/api/account-hooksendpoint that takes the following request type. Sending an auth bearer token should already include the account's user ID.Call the endpoint after successful account creation.
The endpoint can then call
addExampleScreenerToAccount()and will act like a normal API request.I think there are two places we can call the endpoint:
context/AuthContext.jsxand modifyregister(email, password)by usingcreateUserWithEmailAndPassword(auth, email, password).then(someHookFunction).I'm leaning towards putting the API request in the frontend so the hook is stored in the same location as the account creation code and not tied to Firebase.
Michael-Dratch commentedon Mar 12, 2026
This is amazing work! Really appreciate the thought here. I'm not sure about the place to trigger this, specifically the Google login might not distinguish between creating an account and logging in. Also I feel like account creation side effects does feel like a very backend responsibility. But think triggering it here for now would be a good start and we could easily develop a backend function to call the endpoint triggered by firebase auth in the future after further discussion.
I think you should definilty keep going in this direction. Also one small thing. I think it would be good to save the action types as an enum on the backend. We have other enums in the repo that can provide a good example.
feat(seed-data): Add script to export example-screener
feat(seed-data): Add export-example-screener script
feat(seed-data): Add export-example-screener script
feat(seed-data): Add export-example-screener script
feat(seed-data): Add export-example-screener script