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 biometricManager: BiometricManager,
|
||||||
private val getVersionInfo: GetVersionInfoProvider,
|
private val getVersionInfo: GetVersionInfoProvider,
|
||||||
private val standardPreferenceProvider: StandardPreferenceProvider,
|
private val standardPreferenceProvider: StandardPreferenceProvider,
|
||||||
|
private val walletViewModel: WalletViewModel,
|
||||||
) : AndroidViewModel(application) {
|
) : AndroidViewModel(application) {
|
||||||
private val executor: Executor by lazy { ContextCompat.getMainExecutor(application) }
|
private val executor: Executor by lazy { ContextCompat.getMainExecutor(application) }
|
||||||
private lateinit var biometricPrompt: BiometricPrompt
|
private lateinit var biometricPrompt: BiometricPrompt
|
||||||
|
@ -94,10 +95,20 @@ class AuthenticationViewModel(
|
||||||
combine(
|
combine(
|
||||||
isAppAccessAuthenticationRequired.filterNotNull(),
|
isAppAccessAuthenticationRequired.filterNotNull(),
|
||||||
appAccessAuthentication,
|
appAccessAuthentication,
|
||||||
) { required: Boolean, state: AuthenticationUIState ->
|
walletViewModel.secretState,
|
||||||
|
) { required: Boolean, state: AuthenticationUIState, secretState: SecretState ->
|
||||||
when {
|
when {
|
||||||
(!required || versionInfo.isRunningUnderTestService) -> AuthenticationUIState.NotRequired
|
(!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
|
else -> state
|
||||||
}
|
}
|
||||||
}.stateIn(
|
}.stateIn(
|
||||||
|
|
|
@ -118,6 +118,7 @@ fun AuthenticationErrorDialog(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Currently unused, we keep it for further iterations
|
||||||
@Composable
|
@Composable
|
||||||
fun AuthenticationFailedDialog(
|
fun AuthenticationFailedDialog(
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PaymentRequestViewModel(
|
||||||
getMonetarySeparators: GetMonetarySeparatorProvider,
|
getMonetarySeparators: GetMonetarySeparatorProvider,
|
||||||
private val getSpendingKeyUseCase: GetSpendingKeyUseCase,
|
private val getSpendingKeyUseCase: GetSpendingKeyUseCase,
|
||||||
private val getSynchronizer: GetSynchronizerUseCase,
|
private val getSynchronizer: GetSynchronizerUseCase,
|
||||||
private val supportViewModel: SupportViewModel,
|
supportViewModel: SupportViewModel,
|
||||||
walletViewModel: WalletViewModel,
|
walletViewModel: WalletViewModel,
|
||||||
observeAddressBookContacts: ObserveAddressBookContactsUseCase,
|
observeAddressBookContacts: ObserveAddressBookContactsUseCase,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
Loading…
Reference in New Issue