Skip to content

optimize: select and update necessary fields in ChangePassword method #2058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

huiyifyj
Copy link
Contributor

  • Simplify ChangePassword method signature by removing unnecessary return type.
  • Use Select() to fetch only the necessary fields (id and password) from the database.
  • Replace Save() with Update() for more efficient password update operation.

Note: use Save(&user) to update the whole user record, which will cover other unchanged fields as well, causing data inconsistency when data race conditions.

使用 update 替换 save,同时只更新要更新的字段,避免数据竞争时全覆盖造成数据错误。

- Simplify `ChangePassword` method signature by removing unnecessary return type.
- Use `Select()` to fetch only the necessary fields (`id` and `password`) from the database.
- Replace `Save()` with `Update()` for more efficient password update operation.

Note: use `Save(&user)` to update the whole user record, which will cover other unchanged fields as well, causing data inconsistency when data race conditions.
@pixelmaxQm pixelmaxQm changed the base branch from main to v2.8.4-dev July 21, 2025 15:26
@pixelmaxQm pixelmaxQm merged commit ece982c into flipped-aurora:v2.8.4-dev Jul 21, 2025
8 checks passed
@huiyifyj huiyifyj deleted the optimize-gorm-change-pwd branch July 23, 2025 08:06
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.

2 participants