Skip to content

fix(auth): report a rejected refresh in signOut(scope: others) as expired - #2239

Merged
spydon merged 2 commits into
supabase:mainfrom
Franklyn-R-Silva:fix/auth-sign-out-others-reason
Dec 2, 2026
Merged

spydon merged 2 commits into
supabase:mainfrom
Franklyn-R-Silva:fix/auth-sign-out-others-reason

Conversation

@Franklyn-R-Silva

@Franklyn-R-Silva Franklyn-R-Silva commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

signOut(scope: SignOutScope.others) now signs the device out with SignOutReason.sessionExpired instead of SignOutReason.userInitiated when the server rejects the refresh token, as the sign_out and sign_out_reason specs require. SignOutScope.global keeps userInitiated.

Closes #2238

  • _refreshForSignOut picks the reason from the scope. Only the reason changes: the device is still signed out, and signOut still throws an AuthSessionsNotRevokedException.
  • The doc comment of signOut and the sign-out section of MIGRATION.md say which reason each scope reports.
  • The others-scope test in sign_out_scope_test.dart now expects sessionExpired and fails without the fix. The global-scope test still expects userInitiated.

Summary by CodeRabbit

  • Documentation

    • Clarified that rejected refresh tokens result in different sign-out reasons for global sign-out and sign-out of other sessions.
  • Bug Fixes

    • Corrected the documented and tested sign-out reason when other sessions are removed after a refresh-token rejection.
    • Added coverage for signing out an expired session without a refresh token, including the error, cleared session, and signed-out event.

…ired

When the server rejected the refresh token, signOut signed the device out
with SignOutReason.userInitiated for both the global and the others
scope. The others scope does not ask to end this session, which ended
because it expired, so it now reports SignOutReason.sessionExpired.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:46
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When refresh-token rejection ends a session during sign-out with SignOutScope.others, the signed-out reason is now sessionExpired. The migration guide and API documentation describe the scope-specific reasons. Tests cover rejected and missing refresh tokens.

Changes: Sign-out reason behavior

Layer / File(s) Summary
Select and verify the sign-out reason
packages/supabase_auth/lib/src/auth_client.dart, packages/supabase_auth/lib/src/types/sign_out_reason.dart, packages/supabase_auth/test/sign_out_scope_test.dart, MIGRATION.md
When a rejected refresh token leads to local sign-out, SignOutScope.others uses sessionExpired; global scope retains userInitiated. Documentation describes the reasons. Tests verify the rejected-token case and the missing-refresh-token case, including the exception, cleared session, emitted event, and absence of HTTP requests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested labels: auth

Merge Risk: Minimal · up to fd1c9

Signing out other sessions after a rejected refresh token now reports the session-expired reason, as the linked issue requested. The device is still signed out and the same exception is thrown. Documentation and tests were updated to match. I see no remaining merge risk.

Pre-merge checks: Passed 2 · Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #2238 requires that signOut(scope: SignOutScope.others) report SignOutReason.sessionExpired when the refresh token is rejected, keep the device signed out, keep throwing `AuthSessionsNotRevo… Provide the auth_client.dart diff between the merge base and head, or readable head content of signOut and _refreshForSignOut. The evidence must show that the reason is chosen by scope for the rejected-refresh-token path, that the dev…
Out of Scope Changes check Inconclusive The visible changes relate to the linked issue. The others-scope test expectation changes to sessionExpired. A new test covers an expired session with no refresh token and expects the same reason. T… Provide the readable auth_client.dart diff between the merge base and head. Confirm that its code changes are limited to the reason selection in the rejected-refresh-token sign-out path and its documentation.
Passed Passed checks: 2 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavioral change: a rejected refresh token during signOut(scope: others) is now reported with the sessionExpired reason. The raw summary confirms the changes to the others-sc…
Full details: Title check

Explanation

The title names the main behavioral change: a rejected refresh token during signOut(scope: others) is now reported with the sessionExpired reason. The raw summary confirms the changes to the others-scope test, the signOut docs, the sign_out_reason docs, and MIGRATION.md, all of which support this. The title is specific and concise, and it uses the conventional fix(auth) prefix. It does not cover the new test for an expired session without a refresh token, which is expected for a title.

Full details: Linked Issues check

Explanation

Issue #2238 requires that signOut(scope: SignOutScope.others) report SignOutReason.sessionExpired when the refresh token is rejected, keep the device signed out, keep throwing AuthSessionsNotRevokedException, and keep SignOutScope.global on userInitiated. The test diff in packages/supabase_auth/test/sign_out_scope_test.dart changes the others-scope expectation to SignOutReason.sessionExpired and adds a no-refresh-token case. The global-scope expectation is unchanged. The source change that produces this behavior is in packages/supabase_auth/lib/src/auth_client.dart, which the PR description places in _refreshForSignOut. The diff for that file could not be read: the tool reported that changed blobs are missing from the checkout. The file read at head was truncated before the signOut code. The AI summary describes the auth_client.dart change as documentation only, with no implementation change shown. This conflicts with the PR description. The behavior at head is therefore not verified from source. The test expectations and the PR description support compliance, but they do not prove it.

Resolution

Provide the auth_client.dart diff between the merge base and head, or readable head content of signOut and _refreshForSignOut. The evidence must show that the reason is chosen by scope for the rejected-refresh-token path, that the device is still signed out, and that AuthSessionsNotRevokedException is still thrown. Resolve the conflict between the PR description and the AI summary about implementation changes in that file.

Full details: Out of Scope Changes check

Explanation

The visible changes relate to the linked issue. The others-scope test expectation changes to sessionExpired. A new test covers an expired session with no refresh token and expects the same reason. The sign_out_reason.dart documentation and the signOut and MIGRATION.md documentation describe the scope-based reason. These changes support the objective of #2238. The auth_client.dart hunks that contain the implementation change could not be read, so any unrelated code change in that file cannot be ruled out.

Resolution

Provide the readable auth_client.dart diff between the merge base and head. Confirm that its code changes are limited to the reason selection in the rejected-refresh-token sign-out path and its documentation.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 02b9524 and fd1c928.

Files selected for processing: 4

  • MIGRATION.md
  • packages/supabase_auth/lib/src/auth_client.dart
  • packages/supabase_auth/lib/src/types/sign_out_reason.dart
  • packages/supabase_auth/test/sign_out_scope_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@spydon
spydon merged commit 8675b08 into supabase:main Dec 2, 2026
78 of 80 checks passed
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.

signOut(scope: others) reports userInitiated when the refresh token is rejected

3 participants