Skip to content

Commit

Permalink
BIT-2304: Fix pin unlock for new TDE accounts (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-livefront authored Apr 30, 2024
1 parent 13b2739 commit 1006023
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions BitwardenShared/Core/Auth/Repositories/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ extension DefaultAuthRepository: AuthRepository {
publicKey: registrationKeys.publicKey
))

try await stateService.setAccountEncryptionKeys(
AccountEncryptionKeys(
encryptedPrivateKey: registrationKeys.privateKey,
encryptedUserKey: nil
)
)

try await organizationUserAPIService.organizationUserResetPasswordEnrollment(
organizationId: enrollStatus.id,
requestModel: OrganizationUserResetPasswordEnrollmentRequestModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysEmail, "[email protected]")
XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysOrgPublicKey, "MIIBIjAN...2QIDAQAB")
XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysRememberDevice, true)
XCTAssertEqual(
stateService.accountEncryptionKeys["1"],
AccountEncryptionKeys(encryptedPrivateKey: "privateKey", encryptedUserKey: nil)
)
}

/// `createNewSsoUser()` creates a new account for sso JIT user and don't trust device.
Expand Down Expand Up @@ -200,6 +204,10 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
XCTAssertNil(trustDeviceService.trustDeviceWithExistingKeysValue)
XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysOrgPublicKey, "MIIBIjAN...2QIDAQAB")
XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysRememberDevice, false)
XCTAssertEqual(
stateService.accountEncryptionKeys["1"],
AccountEncryptionKeys(encryptedPrivateKey: "privateKey", encryptedUserKey: nil)
)
}

/// `deleteAccount()` deletes the active account and removes it from the state.
Expand Down

0 comments on commit 1006023

Please sign in to comment.