Skip to content

Commit

Permalink
Fix app launch authentication (#1669)
Browse files Browse the repository at this point in the history
- Omit app launch authentication when run without secrets set
  • Loading branch information
HonzaR authored Nov 11, 2024
1 parent 4d35a0d commit d97956d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fun AuthenticationErrorDialog(
)
}

// Currently unused, we keep it for further iterations
@Composable
fun AuthenticationFailedDialog(
onDismiss: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d97956d

Please sign in to comment.