Repository navigation
fix(auth): let forgot-password reset work without the current password - #648
Merged
Merged
Conversation
Two problems stopped the web forgot-password flow from setting a new password: - After the emailed code, afterAuth() sent the recovery session to /app. #503 blocks redirects to /login, which also blocked the reset form at /login?action=changePassword, so the new-password form never appeared. - The reset form used POST /user/change-password. Once a user has chosen a password, GoTrue requires the current one there, which a user who forgot it cannot give (422 incorrect_current_password). Let afterAuth() reach exactly the reset form, and reset through PUT /user like desktop does. GoTrue does not require the current password for sessions opened with an emailed code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideFixes web forgot-password recovery by allowing the recovery session to reach the new-password form and updating the password through GoTrue’s OTP-compatible user endpoint, while retaining current-password behavior for authenticated settings changes. Flow diagram for recovery redirect validationflowchart LR
A[Recovery session completes] --> B{Path is /login?action=changePassword?}
B -->|Yes| C[Show new-password form]
B -->|No| D{Authentication path?}
D -->|Yes| E[Block redirect]
D -->|No| F[Continue normal redirect]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Summary
Follow-up to #647. On web, "Forgot password" could not set a new password. Two independent problems caused this:
afterAuth()redirected the recovery session to/app. fix: prevent first-login failure after logout #503 (forced-login loop fix) blocks every redirect to/login, and that also caught the reset form at/login?action=changePassword. Users landed in the workspace without setting a password. This has been happening since 2026-08-25.afterAuth()now allows exactly/login?action=changePassword./auth/callbackand other login actions stay blocked. The action name now lives insign_in.ts(PASSWORD_RESET_LOGIN_ACTION), andLOGIN_ACTION.CHANGE_PASSWORDreuses it.POST /user/change-password. Once a user has chosen a password (is_non_default_password), GoTrue requires the current one there, and the reset failed with422 incorrect_current_password.PUT /gotrue/user {password}, which desktop already uses for its reset (sign_in_bloc.dart→PasswordHttpService.setupPassword). GoTrue's user update doesn't require the current password for sessions opened with an emailed code (amr: otp), even whenUPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORDis on.Settings → "Change password" (#647) still asks for the current password when GoTrue requires it.
Test plan
TZ=UTC npx jest src/application/session src/components/login src/components/app/settings src/pages …/gotrue-password.test.ts …/gotrue.test.ts: 31 suites, 295 tests passafterAuthreaches the reset form (relative and absolute URLs) and still blocks/auth/callback?action=changePasswordand other login actionsresetPasswordsendsPUT /user {password}with no current password, and drops the session only on 401resetPassword, notchangePasswordpnpm type-checkamr: otp):POST /user/change-password→ 422incorrect_current_passwordPUT /user→ 200, and sign-in with the new password workssame_passwordandweak_passwordcome back as 422s the web already mapsServer note (not changed here)
PUT /userdoesn't check the current password for any session unlessGOTRUE_SECURITY_UPDATE_PASSWORD_REQUIRE_CURRENT_PASSWORDis set. It isn't set locally. So the current-password check on/user/change-passwordstops the UI but isn't a security boundary.🤖 Generated with Claude Code
Summary by Sourcery
Fix web password recovery so users can reach the reset form and set a new password without their forgotten password.
Bug Fixes:
Enhancements:
Tests: