Fix app launch authentication (#1669)
- Omit app launch authentication when run without secrets set
This commit is contained in:
parent
4d35a0d5bc
commit
d97956de44
|
@ -42,6 +42,7 @@ class AuthenticationViewModel(
|
|||
private val biometricManager: BiometricManager,
|
||||
private val getVersionInfo: GetVersionInfoProvider,
|
||||
private val standardPreferenceProvider: StandardPreferenceProvider,
|
||||
private val walletViewModel: WalletViewModel,
|
||||
) : AndroidViewModel(application) {
|
||||
private val executor: Executor by lazy { ContextCompat.getMainExecutor(application) }
|
||||
private lateinit var biometricPrompt: BiometricPrompt
|
||||
|
@ -94,10 +95,20 @@ class AuthenticationViewModel(
|
|||
combine(
|
||||
isAppAccessAuthenticationRequired.filterNotNull(),
|
||||
appAccessAuthentication,
|
||||
) { required: Boolean, state: AuthenticationUIState ->
|
||||
walletViewModel.secretState,
|
||||
) { required: Boolean, state: AuthenticationUIState, secretState: SecretState ->
|
||||
when {
|
||||
(!required || versionInfo.isRunningUnderTestService) -> AuthenticationUIState.NotRequired
|
||||
state == AuthenticationUIState.Initial -> AuthenticationUIState.Required
|
||||
(state == AuthenticationUIState.Initial) -> {
|
||||
if (secretState == SecretState.None ||
|
||||
secretState == SecretState.NeedsWarning
|
||||
) {
|
||||
appAccessAuthentication.value = AuthenticationUIState.NotRequired
|
||||
AuthenticationUIState.NotRequired
|
||||
} else {
|
||||
AuthenticationUIState.Required
|
||||
}
|
||||
}
|
||||
else -> state
|
||||
}
|
||||
}.stateIn(
|
||||
|
|
|
@ -118,6 +118,7 @@ fun AuthenticationErrorDialog(
|
|||
)
|
||||
}
|
||||
|
||||
// Currently unused, we keep it for further iterations
|
||||
@Composable
|
||||
fun AuthenticationFailedDialog(
|
||||
onDismiss: () -> Unit,
|
||||
|
|
|
@ -45,7 +45,7 @@ class PaymentRequestViewModel(
|
|||
getMonetarySeparators: GetMonetarySeparatorProvider,
|
||||
private val getSpendingKeyUseCase: GetSpendingKeyUseCase,
|
||||
private val getSynchronizer: GetSynchronizerUseCase,
|
||||
private val supportViewModel: SupportViewModel,
|
||||
supportViewModel: SupportViewModel,
|
||||
walletViewModel: WalletViewModel,
|
||||
observeAddressBookContacts: ObserveAddressBookContactsUseCase,
|
||||
) : ViewModel() {
|
||||
|
|
Loading…
Reference in New Issue