PM-10286: VerificationCodeScreen should not show MP reprompt if there is no master password (#5336)

This commit is contained in:
David Perez
2025-06-09 14:32:02 -05:00
committed by GitHub
parent c60df56648
commit a0c2600517
3 changed files with 12 additions and 7 deletions

View File

@@ -57,6 +57,11 @@ class VerificationCodeViewModel @Inject constructor(
viewState = VerificationCodeState.ViewState.Loading,
dialogState = null,
isRefreshing = false,
hasMasterPassword = authRepository
.userStateFlow
.value
?.activeAccount
?.hasMasterPassword == true,
)
},
) {
@@ -83,11 +88,8 @@ class VerificationCodeViewModel @Inject constructor(
listDataState
}
}
.onEach {
sendAction(
VerificationCodeAction.Internal.AuthCodesReceive(it),
)
}
.map { VerificationCodeAction.Internal.AuthCodesReceive(it) }
.onEach(::sendAction)
.launchIn(viewModelScope)
}
@@ -363,7 +365,7 @@ class VerificationCodeViewModel @Inject constructor(
VerificationCodeDisplayItem(
id = item.id,
authCode = item.code,
hideAuthCode = item.hasPasswordReprompt,
hideAuthCode = item.hasPasswordReprompt && state.hasMasterPassword,
label = item.name,
supportingLabel = item.username,
periodSeconds = item.periodSeconds,
@@ -412,6 +414,7 @@ data class VerificationCodeState(
val dialogState: DialogState?,
val isPullToRefreshSettingEnabled: Boolean,
val isRefreshing: Boolean,
val hasMasterPassword: Boolean,
) : Parcelable {
/**

View File

@@ -518,4 +518,5 @@ private val DEFAULT_STATE = VerificationCodeState(
isPullToRefreshSettingEnabled = false,
dialogState = null,
isRefreshing = false,
hasMasterPassword = false,
)

View File

@@ -64,6 +64,7 @@ class VerificationCodeViewModelTest : BaseViewModelTest() {
private val mockUserAccount: UserState.Account = mockk {
every { isPremium } returns true
every { hasMasterPassword } returns true
}
private val mockUserState: UserState = mockk {
@@ -602,7 +603,6 @@ class VerificationCodeViewModelTest : BaseViewModelTest() {
authRepository = authRepository,
)
@Suppress("MaxLineLength")
private fun createVerificationCodeState(
viewState: VerificationCodeState.ViewState = VerificationCodeState.ViewState.Loading,
) = VerificationCodeState(
@@ -613,6 +613,7 @@ class VerificationCodeViewModelTest : BaseViewModelTest() {
dialogState = null,
isPullToRefreshSettingEnabled = settingsRepository.getPullToRefreshEnabledFlow().value,
isRefreshing = false,
hasMasterPassword = true,
)
private fun createDisplayItemList() = listOf(