-
Notifications
You must be signed in to change notification settings - Fork 54
Feature request: Tell onSuccess if the user has signed up or just signed in #372
Copy link
Copy link
Open
Description
Problem:
I'm using the WorkOS events API to sync user profiles, organisations and org memberships to my own database for use in authorization checks and to model relations between entities and users/orgs.
When a user signs up or logs in, the onSuccess callback triggers a check to see if the user exists in our database or not, and creates records for them if not. We have some specific logic that needs to run only on sign-up but before users can access the app (therefor the event syncing background job may not have completed)
Proposed solution(s)
- Pass an additional arg to the
onSuccesscallback
export interface HandleAuthOptions {
//...rest
eventType: 'sign-up' | 'sign-in';
}
export const GET = handleAuth({
async onSuccess({ eventType }) {
if (eventType === 'sign-up') {
await additionalOnboardingLogic()
}
}
})- Provide different callbacks for sign up and sign in
Alternatives I've considered
- Passing the
stateparam togetSignUpUrlto differentiate sign-up from sign-in, but a user is able to click log in and then from the hosted AuthKit UI, change the flow to sign-up. This means the state param would then be invalid. - Using webhooks instead in the hope they will be delivered in time for our onboarding logic to run, but I'd rather use the events API instead where possible since WorkOS has no capability for simulating webhooks for testing as stripe does
- Holding the user on a page until the background sync has finished: I'll probably have to do this for now
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels