Skip to content

fix: only trigger after-user-created hook on account creation - #2656

Open
swithek wants to merge 1 commit into
supabase:masterfrom
swithek:fix/after-user-created-fires-on-every-oauth-signin
Open

fix: only trigger after-user-created hook on account creation#2656
swithek wants to merge 1 commit into
supabase:masterfrom
swithek:fix/after-user-created-fires-on-every-oauth-signin

Conversation

@swithek

@swithek swithek commented Jul 30, 2026

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

The external OAuth callback sets createdUser = true unconditionally, discarding the models.AccountLinkingDecision. That branch handles every OAuth sign-in, so after-user-created also fires for AccountExists (returning user) and LinkAccount (new identity on an existing user). Hook side effects therefore repeat on every sign-in, and since the hook's error propagates out of the callback, a hook that rejects a duplicate user breaks all OAuth sign-ins.

What is the new behavior?

createdUser is gated on decision == models.CreateAccount, matching the existing call sites in token_oidc.go, web3.go and samlacs.go.

Additional context

Two regression tests in ExternalTestSuite cover the AccountExists and LinkAccount paths.

The external OAuth callback set createdUser unconditionally, so the hook
also fired for AccountExists and LinkAccount, repeating side effects on
every sign-in.
@swithek
swithek requested a review from a team as a code owner July 30, 2026 10:19
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.

1 participant