Skip to content

feat(auth): send PKCE code_challenge in updateUser when changing email#1601

Merged
spydon merged 4 commits into
mainfrom
worktree-SDK-1318
Jul 15, 2026
Merged

feat(auth): send PKCE code_challenge in updateUser when changing email#1601
spydon merged 4 commits into
mainfrom
worktree-SDK-1318

Conversation

@spydon

@spydon spydon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Under the PKCE flow, updateUser({ email }) now generates a PKCE code verifier and sends the corresponding code_challenge / code_challenge_method in the request body, mirroring what resend() and getSSOSignInUrl already do. This lets an email change started under PKCE complete via exchangeCodeForSession().

The fields are only added when an email is being changed, so no public API surface or return type changes. Non-PKCE flows are unaffected (the challenge is null).

Outcome

implemented

Reference

  • supabase-js parity, following the already-shipped Dart resend() PKCE work (SDK-1023).

Compliance matrix

  • auth.session.update_userimplemented (was partially_implemented).

Tests

  • Added mock tests in packages/gotrue/test/otp_mock_test.dart: PKCE email change includes the code challenge, non-email updates omit it, and implicit flow omits it.

Closes SDK-1318

@spydon
spydon requested a review from a team as a code owner July 15, 2026 09:21
@github-actions github-actions Bot added the auth This issue or pull request is related to authentication label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@spydon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 161ef2e5-90d3-4a6d-a156-92d5303024c9

📥 Commits

Reviewing files that changed from the base of the PR and between 5c9757f and 7d4f227.

📒 Files selected for processing (1)
  • packages/gotrue/test/client_test.dart
📝 Walkthrough

Walkthrough

GoTrueClient.updateUser now adds PKCE code challenge fields to email update requests when the configured flow supports them, while non-email updates and implicit-flow updates omit those fields. Mock client support captures and responds to user updates. Tests cover PKCE, non-email, implicit-flow, and end-to-end email verification exchanges. SDK compliance metadata marks user session updates as implemented.

Sequence Diagram(s)

sequenceDiagram
  participant GoTrueClient
  participant AuthServer
  participant Mailpit
  GoTrueClient->>AuthServer: Update email with PKCE challenge
  AuthServer->>Mailpit: Send verification email
  GoTrueClient->>Mailpit: Retrieve verification code
  GoTrueClient->>AuthServer: Exchange code for session
  AuthServer-->>GoTrueClient: Return session with updated email
Loading

Suggested labels: auth


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spydon
spydon merged commit 59d349e into main Jul 15, 2026
31 checks passed
@spydon
spydon deleted the worktree-SDK-1318 branch July 15, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth This issue or pull request is related to authentication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants