Repository navigation
Call the app's user.deleted handler even without a stored user - #82
Open
dominicwild wants to merge 1 commit into
Open
dominicwild wants to merge 1 commit into
dominicwild wants to merge 1 commit into
Conversation
commit: |
Member
|
@cubic review |
@ianmacartney I have started the AI code review. It will take a few minutes to complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #77,
user.deletedrecords the id indeletedUsers, and then returns early without calling the app'sonEventhandler if the component has no stored user for that id.That's fine for apps that create their users only from the component's
user.createdcallback. It loses the deletion for apps that also create their own user records some other way, for example at sign-in. WorkOS doesn't guarantee delivery order (docs). So whenuser.deletedarrives beforeuser.created, such an app's account is never deleted. The lateruser.createdis then skipped too, so the app never hears about the user again.This change passes the deletion on to the app handler in that case, with the event data as received. Everything else stays the same: event deduplication, the
deletedUsersrecord, filling in the callback data from a stored user when one exists, and skipping later create and update events for a deleted id.src/component/lib.test.ts: the handler is called once for a deletion with no stored user (full payload and id-only payload), and later create and update events are still skipped.example/convex/auth.test.ts: an app user that exists without a component user is removed byuser.deleted.idis guaranteed inevent.data.npm run build,test,lintandtypecheckpass.