Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public async Task<IdentityResult> PasswordChangeAndRotateUserAccountKeysAsync(Us
user.Key = model.MasterPasswordUnlockData.MasterKeyWrappedUserKey;
user.MasterPassword = _passwordHasher.HashPassword(user, model.MasterPasswordAuthenticationData.MasterPasswordAuthenticationHash);
user.MasterPasswordHint = model.MasterPasswordHint;
user.LastPasswordChangeDate = DateTime.UtcNow;
Comment thread
Thomas-Avery marked this conversation as resolved.

await _userRepository.UpdateUserKeyAndEncryptedDataV2Async(user, saveEncryptedDataActions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public async Task UpdateUserKeyAndEncryptedDataV2Async(Core.Entities.User user,

userEntity.MasterPassword = user.MasterPassword;
userEntity.MasterPasswordHint = user.MasterPasswordHint;
userEntity.LastPasswordChangeDate = user.LastPasswordChangeDate;

userEntity.LastKeyRotationDate = user.LastKeyRotationDate;
userEntity.AccountRevisionDate = user.AccountRevisionDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,21 @@ public async Task PasswordChangeAndRotateUserAccountKeysAsync_V1_Success(SutProv
var signatureRepository = sutProvider.GetDependency<IUserSignatureKeyPairRepository>();
SetV1ExistingUser(user, signatureRepository);
SetV1ModelUser(model.BaseData);
user.LastPasswordChangeDate = DateTime.UtcNow.AddDays(-1);
user.LastKeyRotationDate = DateTime.UtcNow.AddDays(-1);

sutProvider.GetDependency<IUserService>().CheckPasswordAsync(user, model.OldMasterKeyAuthenticationHash)
.Returns(true);

var before = DateTime.UtcNow;
var result = await sutProvider.Sut.PasswordChangeAndRotateUserAccountKeysAsync(user, model);
var after = DateTime.UtcNow;

Assert.Equal(IdentityResult.Success, result);
Assert.NotNull(user.LastPasswordChangeDate);
Assert.InRange(user.LastPasswordChangeDate.Value, before, after);
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
Comment thread
Thomas-Avery marked this conversation as resolved.
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
Assert.NotNull(user.LastKeyRotationDate);
Assert.InRange(user.LastKeyRotationDate.Value, before, after);
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
}

[Theory, BitAutoData]
Expand All @@ -147,9 +156,16 @@ public async Task PasswordChangeAndRotateUserAccountKeysAsync_UpgradeV1ToV2_Succ
sutProvider.GetDependency<IUserService>().CheckPasswordAsync(user, model.OldMasterKeyAuthenticationHash)
.Returns(true);

var before = DateTime.UtcNow;
var result = await sutProvider.Sut.PasswordChangeAndRotateUserAccountKeysAsync(user, model);
var after = DateTime.UtcNow;

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);
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
Assert.NotNull(user.LastKeyRotationDate);
Assert.InRange(user.LastKeyRotationDate.Value, before, after);
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
}


Expand Down
Loading