Repository navigation
feat: support first bind update password - #2520
Calcium-Ion merged 1 commit into
Conversation
WalkthroughThe changes enable initial password binding by relaxing validation requirements in both backend and frontend. The backend now skips original password validation when no current password exists, while the frontend removes the empty original password check, allowing first-time password creation without pre-existing credentials. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 0
🧹 Nitpick comments (2)
web/src/components/settings/PersonalSetting.jsx (2)
317-320: Remove commented-out code.Instead of leaving the validation commented out, please remove these lines entirely to keep the codebase clean.
🔎 Proposed fix
- // if (inputs.original_password === '') { - // showError(t('请输入原密码!')); - // return; - // } if (inputs.set_new_password === '') {
325-327: Consider improving UX for first-time password binding.The validation message "新密码需要和原密码不一致!" (new password must differ from original password) may confuse users who are setting their password for the first time via OAuth, as they have no original password. While the logic is functionally correct, consider conditionally showing this check only when an original password exists, or adjusting the error message.
💡 Example improvement
- if (inputs.original_password === inputs.set_new_password) { + if (inputs.original_password !== '' && inputs.original_password === inputs.set_new_password) { showError(t('新密码需要和原密码不一致!')); return; }This way, the check only applies when the user has provided an original password.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
controller/user.goweb/src/components/settings/PersonalSetting.jsx
🔇 Additional comments (1)
controller/user.go (1)
768-773: LGTM! The logic correctly handles password validation for OAuth users.The added condition
&& currentUser.Password != ""prevents validation errors for OAuth users binding their first password. Since bcrypt hashes have a specific format, attempting to validate an empty password would fail, making this guard clause necessary. The fix maintains security by:
- Only skipping validation for users without existing passwords (OAuth users)
- Still requiring the new password to be non-empty
- Preserving validation for users with existing passwords
支持第三方登录后修改密码,
以支持通过用户名密码登录
Summary by CodeRabbit
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.