fix: Reset Password page stuck in loop for OAuth-linked accounts#38604
fix: Reset Password page stuck in loop for OAuth-linked accounts#38604ritikpal1122 wants to merge 4 commits into
Conversation
…ketChat#36698) Co-Authored-By: Ritik Pal <er.ritikpal@gmail.com>
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughExpanded password-change gating in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (1)📚 Learning: 2025-10-07T15:08:37.419ZApplied to files:
🧬 Code graph analysis (1)apps/meteor/server/methods/saveUserProfile.ts (2)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/meteor/server/methods/saveUserProfile.ts`:
- Around line 125-127: The inner condition that checks settings.newPassword and
rcSettings.get<boolean>('Accounts_AllowPasswordChange') currently blocks users
with user?.requirePasswordChange from updating their password; update the
conditional in saveUserProfile.ts so that if user?.requirePasswordChange is true
it bypasses the Accounts_AllowPasswordChange check (i.e., allow the branch when
settings.newPassword is provided OR user.requirePasswordChange is true),
ensuring the code path that sets the new password and clears
user.requirePasswordChange still runs; adjust any related logic that clears the
flag so it executes after a successful password update in the same block that
handles new passwords (referencing canChangePasswordForOAuth,
user?.services?.password, user?.requirePasswordChange, settings.newPassword, and
rcSettings.get<boolean>('Accounts_AllowPasswordChange')).
🧹 Nitpick comments (1)
apps/meteor/server/methods/saveUserProfile.ts (1)
129-129: Nit: Code comment in implementation.As per coding guidelines, "Avoid code comments in the implementation".
Proposed fix
- // don't let user change to same password - if (await compareUserPassword(user, { plain: settings.newPassword })) { + if (await compareUserPassword(user, { plain: settings.newPassword })) {
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/meteor/server/methods/saveUserProfile.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/server/methods/saveUserProfile.ts
🔇 Additional comments (2)
apps/meteor/server/methods/saveUserProfile.ts (2)
128-141: Guarding same-password and history checks behindbcryptexistence looks correct.This ensures OAuth-only users without an existing local password can set one without hitting the same-password or password-history errors. The
passwordPolicy.validate(line 143) andAccounts.setPasswordAsync(line 145) remain outside this guard, which is the right behavior — all users get policy enforcement.
155-161: GuardingaddPasswordToHistorybehindbcryptexistence is correct.No bcrypt hash means nothing meaningful to store in history.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
e379c61 to
4b66e9b
Compare
Summary
Fixes #36698
user?.services?.password?.bcryptfrom the password-change gate condition so OAuth users without an existing local password can set one and clearrequirePasswordChangeaddPasswordToHistorybehinduser?.services?.password?.bcryptsince they only apply when the user already has a local passworduser?.requirePasswordChangeto the outer guard so users flagged by the system can always set a password, even ifAccounts_AllowPasswordChangeForOAuthUsersis disabledRoot Cause
When an OAuth user (e.g., Google login) with a pre-existing unverified local account logs in,
requirePasswordChangeis set totrueand they're redirected to the Reset Password page. The "Reset" button callssaveUserProfile(), but thepassword-change block required
user.services.password.bcryptto exist — which it doesn't for OAuth-only users. This meant:requirePasswordChangewas never clearedTest plan
Accounts_AllowPasswordChangeForOAuthUsersdisabled butrequirePasswordChangetrue can still set passwordSummary by CodeRabbit
Bug Fixes
Security