Skip to content

fix(auth): return null user and session for email_change single-confirmation verifyOtp#2378

Merged
mandarini merged 1 commit into
masterfrom
fix/verify-otp-email-change-null-user
May 18, 2026
Merged

fix(auth): return null user and session for email_change single-confirmation verifyOtp#2378
mandarini merged 1 commit into
masterfrom
fix/verify-otp-email-change-null-user

Conversation

@mandarini

@mandarini mandarini commented May 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #2377. When secure email change is enabled, gotrue's POST /verify returns { msg, code } (200 OK) after the first of two confirmations succeeds. _sessionResponse was falling through to a (data as User) cast, so verifyOtp({ type: 'email_change' }) surfaced the message object as data.user, contradicting the declared AuthResponse type.

This drops the unsafe fallback in _sessionResponse and returns { user: null, session: null } for that branch, then tightens verifyOtp's local user annotation to match. Adds unit tests for _sessionResponse (session present, single-confirmation, user-without-session) and a mocked-fetch test for verifyOtp covering the reported case. No behavior change for any other caller of _sessionResponse.

@mandarini mandarini requested review from a team as code owners May 18, 2026 12:29
@github-actions github-actions Bot added the auth-js Related to the auth-js library. label May 18, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2378

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2378

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2378

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2378

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2378

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2378

commit: 5b60405

@mandarini mandarini merged commit ffa2894 into master May 18, 2026
25 checks passed
@mandarini mandarini deleted the fix/verify-otp-email-change-null-user branch May 18, 2026 12:45
mandarini pushed a commit to supabase/ssr that referenced this pull request May 18, 2026
This PR updates `@supabase/supabase-js` to v2.106.0.

**Source**: supabase-js-stable-release

---

## Release Notes

## v2.106.0

## 2.106.0 (2026-05-18)

### 🚀 Features

- **supabase:** W3C/OpenTelemetry trace context propagation
([#2163](supabase/supabase-js#2163))

### 🩹 Fixes

- **auth:** return null user and session for email_change
single-confirmation verifyOtp
([#2378](supabase/supabase-js#2378))
- **release:** mark @supabase/tracing private and snapshot it for JSR
([#2370](supabase/supabase-js#2370))
- **storage:** make StreamDownloadBuilder implement Promise and memoize
executor ([#2367](supabase/supabase-js#2367))

### ❤️ Thank You

- Claude Sonnet 4.5
- Guilherme Souza
- Katerina Skroumpelou @mandarini
- oniani1

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
mandarini pushed a commit to supabase/supabase that referenced this pull request May 19, 2026
This PR updates @supabase/*-js libraries to version 2.106.0.

**Source**: supabase-js-stable-release

**Changes**:
- Updated @supabase/supabase-js to 2.106.0
- Updated @supabase/auth-js to 2.106.0
- Updated @supabase/realtime-js to 2.106.0
- Updated @supabase/postgest-js to 2.106.0
- Refreshed pnpm-lock.yaml

---

## Release Notes

## v2.106.0

## 2.106.0 (2026-05-18)

### 🚀 Features

- **supabase:** W3C/OpenTelemetry trace context propagation
([#2163](supabase/supabase-js#2163))

### 🩹 Fixes

- **auth:** return null user and session for email_change
single-confirmation verifyOtp
([#2378](supabase/supabase-js#2378))
- **release:** mark @supabase/tracing private and snapshot it for JSR
([#2370](supabase/supabase-js#2370))
- **storage:** make StreamDownloadBuilder implement Promise and memoize
executor ([#2367](supabase/supabase-js#2367))

### ❤️ Thank You

- Claude Sonnet 4.5
- Guilherme Souza
- Katerina Skroumpelou @mandarini
- oniani1

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth-js Related to the auth-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect type for verifyOtp email_change

2 participants