diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt index 05bc6e467..c0e6ef8c9 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt @@ -89,6 +89,11 @@ interface AuthRepository : AuthenticatorProvider, AuthRequestManager { */ var rememberedOrgIdentifier: String? + /** + * The currently persisted state indicating whether the user has trusted this device. + */ + var shouldTrustDevice: Boolean + /** * Tracks whether there is an additional account that is pending login/registration in order to * have multiple accounts available. 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 959f9d1cc..3a4242aae 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 @@ -252,6 +252,8 @@ class AuthRepositoryImpl( override var rememberedOrgIdentifier: String? by authDiskSource::rememberedOrgIdentifier + override var shouldTrustDevice: Boolean by authDiskSource::shouldTrustDevice + override var hasPendingAccountAddition: Boolean by mutableHasPendingAccountAdditionStateFlow::value 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 0f67ad758..f425fe6ed 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 @@ -518,6 +518,21 @@ class AuthRepositoryTest { assertNull(repository.rememberedOrgIdentifier) } + @Test + fun `shouldTrustDevice should directly access the authDiskSource`() { + // AuthDiskSource and the repository start with the same default value. + assertFalse(repository.shouldTrustDevice) + assertFalse(fakeAuthDiskSource.shouldTrustDevice) + + // Updating the repository updates AuthDiskSource + repository.shouldTrustDevice = true + assertTrue(fakeAuthDiskSource.shouldTrustDevice) + + // Updating AuthDiskSource updates the repository + fakeAuthDiskSource.shouldTrustDevice = false + assertFalse(repository.shouldTrustDevice) + } + @Test fun `passwordResetReason should pull from the user's profile in AuthDiskSource`() = runTest { val updatedProfile = ACCOUNT_1.profile.copy(