Skip to content

fix(auth): preserve credentials during account updates - #22507

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
6ba3i:feat/admin-password-policy-hook
Nov 19, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
6ba3i:feat/admin-password-policy-hook

Conversation

@6ba3i

@6ba3i 6ba3i commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Prevent stale account updates from restoring credentials and provide an admin password policy hook.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Admin password changes now pass the authenticated actor ID to the service for a target check. Password login and settings updates use conditional, field-specific database updates to protect current credentials from stale writes.

Changes: Admin Password Change

Layer / File(s) Summary
Admin password-change actor check
internal/admin/handler.go, internal/admin/service.go, internal/admin/stub.go, internal/admin/change_password_test.go
The handler passes the authenticated user ID to the service. The service checks the actor-target relationship before proceeding with the password change. Community-build helpers and a test cover the community route behavior.

User Credential Updates

Layer / File(s) Summary
Conditional password login update
internal/service/user.go, internal/service/user_password_login_test.go
Both password login paths use a shared helper that updates the access token and last-login time only when the stored password matches the password used for authentication. Tests cover successful login and rejection of a stale password.
Field-specific settings update
internal/service/user.go, internal/service/user_password_login_test.go
Settings updates persist only supplied fields. Password updates also match the previously loaded password hash and return a conflict if the update does not affect one row. A test checks that stale credentials are not restored.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested labels: 🐞 bug

Suggested reviewers: wangq8, buua436, jinhai-cn

Merge Risk: Minimal · up to 976ae

This change protects current credentials from stale account updates and passes the acting admin's ID to the password-change service. No concrete merge-blocking problem was found. The only open point is whether the downstream enterprise build supplies the two new admin helper functions.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title uses the conventional commit form and names the main change: preserving credentials during account updates. The raw summary shows the core change is that stale account updates no longer over…
Description check Passed The description has one sentence stating the purpose: preventing stale account updates from restoring credentials, and providing an admin password policy hook. It lacks the template's Summary heading …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the conventional commit form and names the main change: preserving credentials during account updates. The raw summary shows the core change is that stale account updates no longer overwrite stored password data, through the password-conditioned update and the settings update path. The title is specific enough for a teammate to understand the primary change. It does not mention the admin password policy hook, which the description also lists, but the title does not need to cover every detail.

Full details: Description check

Explanation

The description has one sentence stating the purpose: preventing stale account updates from restoring credentials, and providing an admin password policy hook. It lacks the template's Summary heading and does not give background context for reviewers, such as why stale updates occur or how the fix works. The raw summary also shows the change includes a new actor-target check for admin password changes, which the description does not mention. The description is brief but it states the aim, so it is mostly complete against the template.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

A rabbit checks the password path,
And keeps stale tokens from the math.
The fields update one by one,
The login waits until checks are done.
Credentials stay in their place,
While carrots bounce through database space.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c41d2c1-e80b-42d0-b1a7-611c6cb9cc8b
Commits

Reviewing files that changed from the base of the PR and between 2c1adcf and 976aeee.

Files selected for processing: 6

  • internal/admin/change_password_test.go
  • internal/admin/handler.go
  • internal/admin/service.go
  • internal/admin/stub.go
  • internal/service/user.go
  • internal/service/user_password_login_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@wangq8
wangq8 requested a review from buua436 November 19, 2026 03:01
@6ba3i 6ba3i added the ci Continue Integration label Nov 19, 2026

@buua436 buua436 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangq8
wangq8 merged commit a0ba030 into infiniflow:main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants