fix: invalidate sessions on password change & redesign account page#790
Conversation
- Invalidate all sessions when admin resets a member's password via deleteMany on the session model - Revoke other sessions when a user changes their own password via revokeOtherSessions flag - Redesign account page: inline profile name editing, email display, password change/set moved into FormDialog dialogs - Add updateUserName mutation for display name changes - Hide Edit action on own member row, fix Transfer ownership text wrapping - Add tests for set_member_password, update_user_password, update_user_name - Add translation keys for profile section and toast messages
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis PR refactors the account settings form into modular ProfileSection and PasswordSection components, each managing independent form state and validation. It introduces a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 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. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@services/platform/app/features/settings/account/components/account-form.tsx`:
- Around line 66-70: The name field must be normalized (trimmed) before
validation and when resetting the form: update the profileSchema (the useMemo
that defines profileSchema) to preprocess/transform the input string to s.trim()
before applying min(1, tSettings(...)) so whitespace-only values are rejected,
and when calling the form reset/sync after save (the code that references
user.name and the reset/update logic around lines 86-99), pass user.name?.trim()
(or the normalized value from the form result) so the form state is set to the
trimmed display name; apply the same trimming normalization to any other
client-side validation/reset paths that handle name.
In `@services/platform/convex/users/set_member_password.ts`:
- Around line 133-140: The deleteMany call using
ctx.runMutation(components.betterAuth.adapter.deleteMany, ...) only removes up
to paginationOpts.numItems (100) sessions, so loop until no sessions remain:
repeatedly call ctx.runMutation with the same input (model: 'session', where
userId == memberUserId) and paginationOpts (cursor: null, numItems: 100) and
break when the result indicates zero deleted items; alternatively, if
components.betterAuth.adapter exposes a bulk delete-all for model 'session' or
accepts no pagination, call that instead to remove all sessions in one
operation; update the code around the session invalidation block to perform the
loop or use the adapter's delete-all API for memberUserId.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0ad0ad98-399b-4c90-a2a3-e2cd8b2adbcc
⛔ Files ignored due to path filters (1)
services/platform/convex/_generated/api.d.tsis excluded by!**/_generated/**
📒 Files selected for processing (11)
services/platform/app/features/settings/account/components/account-form.tsxservices/platform/app/features/settings/account/hooks/mutations.tsservices/platform/app/features/settings/organization/components/member-row-actions.tsxservices/platform/convex/users/__tests__/set_member_password.test.tsservices/platform/convex/users/__tests__/update_user_name.test.tsservices/platform/convex/users/__tests__/update_user_password.test.tsservices/platform/convex/users/mutations.tsservices/platform/convex/users/set_member_password.tsservices/platform/convex/users/update_user_name.tsservices/platform/convex/users/update_user_password.tsservices/platform/messages/en.json
66d7188 to
a2e82b8
Compare
Summary
setMemberPassword, all sessions for that user are deleted viadeleteMany. When a user changes their own password viaupdateUserPassword,revokeOtherSessions: trueis passed to better-auth'schangePasswordAPI.updateUserNamemutation. Email is shown as read-only. Password change/set forms are moved intoFormDialogdialogs for a cleaner UX.contentWidthonEntityRowActions.set_member_password(session invalidation, auth checks, credential create/update),update_user_password(session revocation, validation), andupdate_user_name(validation, trimming, auth).updateUserNamefor display name changes via the better-auth adapter.Closes #771
Test plan
bun run --filter @tale/platform testto confirm all new tests passSummary by CodeRabbit
New Features
Improvements
Localization