diff --git a/BitwardenShared/Core/Auth/Repositories/AuthRepository.swift b/BitwardenShared/Core/Auth/Repositories/AuthRepository.swift index 2bdcd2aef..803dec7fa 100644 --- a/BitwardenShared/Core/Auth/Repositories/AuthRepository.swift +++ b/BitwardenShared/Core/Auth/Repositories/AuthRepository.swift @@ -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( diff --git a/BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift b/BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift index eb4a6edc6..9523a6698 100644 --- a/BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift +++ b/BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift @@ -171,6 +171,10 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo XCTAssertEqual(clientService.mockAuth.makeRegisterTdeKeysEmail, "user@bitwarden.com") 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. @@ -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.