Skip to content

[PM-38613] Add timestamp for LastPasswordChangeDate#7768

Open
Thomas-Avery wants to merge 6 commits into
mainfrom
km/add-password-change-date
Open

[PM-38613] Add timestamp for LastPasswordChangeDate#7768
Thomas-Avery wants to merge 6 commits into
mainfrom
km/add-password-change-date

Conversation

@Thomas-Avery

@Thomas-Avery Thomas-Avery commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38613

📔 Objective

When a user key and password change rotation happens we want to indicate a password change has happen by setting the LastPasswordChangeDate.

@Thomas-Avery Thomas-Avery requested a review from a team as a code owner June 5, 2026 15:10
@Thomas-Avery Thomas-Avery requested a review from mzieniukbw June 5, 2026 15:11
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: REQUEST CHANGES

PR adds user.LastPasswordChangeDate = DateTime.UtcNow to PasswordChangeAndRotateUserAccountKeysAsync so the password change timestamp is recorded when a key rotation is paired with a master-password change (PM-38613). The change is a single line in RotateUserAccountKeysCommand.cs. The intent is correct and consistent with how LastPasswordChangeDate is updated elsewhere (e.g., MasterPasswordService, UserService, EmergencyAccessService, AdminRecoverAccountCommand), but the persistence layer on EF Core does not carry this field through, so the fix lands on MSSQL only.

Code Review Details
  • ❌ : LastPasswordChangeDate is silently dropped on EF Core backends (MySQL/PostgreSQL/SQLite) because UpdateUserKeyAndEncryptedDataV2Async does not copy it onto the tracked entity
    • src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountKeysCommand.cs:96

Additional, low-impact: no unit test was added asserting the new LastPasswordChangeDate assignment; a small test on PasswordChangeAndRotateUserAccountKeysAsync would lock in the behavior and align with the project rule to add tests for new feature work.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.74%. Comparing base (3a09bca) to head (7cbad49).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7768   +/-   ##
=======================================
  Coverage   65.74%   65.74%           
=======================================
  Files        2219     2219           
  Lines       98064    98066    +2     
  Branches     8849     8849           
=======================================
+ Hits        64471    64473    +2     
  Misses      31379    31379           
  Partials     2214     2214           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mzieniukbw
mzieniukbw previously approved these changes Jun 5, 2026
@quexten quexten self-assigned this Jun 18, 2026
@sonarqubecloud

Copy link
Copy Markdown


Assert.Equal(IdentityResult.Success, result);
Assert.NotNull(user.LastPasswordChangeDate);
Assert.InRange(user.LastPasswordChangeDate.Value, before, after);
Assert.NotNull(user.LastPasswordChangeDate);
Assert.InRange(user.LastPasswordChangeDate.Value, before, after);
Assert.NotNull(user.LastKeyRotationDate);
Assert.InRange(user.LastKeyRotationDate.Value, before, after);
Assert.Equal(IdentityResult.Success, result);
Assert.Equal(user.SecurityState, model.BaseData.AccountKeys.SecurityStateData!.SecurityState);
Assert.NotNull(user.LastPasswordChangeDate);
Assert.InRange(user.LastPasswordChangeDate.Value, before, after);
Assert.NotNull(user.LastPasswordChangeDate);
Assert.InRange(user.LastPasswordChangeDate.Value, before, after);
Assert.NotNull(user.LastKeyRotationDate);
Assert.InRange(user.LastKeyRotationDate.Value, before, after);
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.

3 participants