diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index bb1dd8567..d5c6652c2 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -473,9 +473,8 @@ class AuthRepositoryImpl( requestPrivateKey = requestPrivateKey, method = AuthRequestMethod.UserKey(protectedUserKey = asymmetricalKey), ), - // We can separately unlock vault for organization data after - // receiving the sync response if this data is currently absent. - organizationKeys = null, + // We should already have the org keys from the login sync. + organizationKeys = authDiskSource.getOrganizationKeys(userId = userId), ) authDiskSource.storeUserKey(userId = userId, userKey = asymmetricalKey) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index 205a9fb07..723489ae1 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -1257,8 +1257,10 @@ class AuthRepositoryTest { val requestPrivateKey = "requestPrivateKey" val asymmetricalKey = "asymmetricalKey" val privateKey = "privateKey" + val orgKeys = mapOf("orgId" to "orgKey") fakeAuthDiskSource.userState = SINGLE_USER_STATE_1 fakeAuthDiskSource.storePrivateKey(userId = USER_ID_1, privateKey = privateKey) + fakeAuthDiskSource.storeOrganizationKeys(userId = USER_ID_1, organizationKeys = orgKeys) coEvery { vaultRepository.unlockVault( userId = USER_ID_1, @@ -1269,7 +1271,7 @@ class AuthRepositoryTest { requestPrivateKey = requestPrivateKey, method = AuthRequestMethod.UserKey(protectedUserKey = asymmetricalKey), ), - organizationKeys = null, + organizationKeys = orgKeys, ) } returns VaultUnlockResult.Success coEvery { vaultRepository.syncIfNecessary() } just runs @@ -1289,7 +1291,7 @@ class AuthRepositoryTest { requestPrivateKey = requestPrivateKey, method = AuthRequestMethod.UserKey(protectedUserKey = asymmetricalKey), ), - organizationKeys = null, + organizationKeys = orgKeys, ) vaultRepository.syncIfNecessary() }