Added TanExpiredCallback to close EnterTanDialog when TAN has expired

This commit is contained in:
dankito 2024-09-09 17:28:22 +02:00
parent 8f774361e9
commit 66d9214c4f
1 changed files with 20 additions and 0 deletions

View File

@ -18,13 +18,16 @@ import bankmeister.composeapp.generated.resources.zoom_in
import bankmeister.composeapp.generated.resources.zoom_out
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import net.codinux.banking.client.model.tan.ActionRequiringTan
import net.codinux.banking.client.model.tan.AllowedTanFormat
import net.codinux.banking.client.model.tan.EnterTanResult
import net.codinux.banking.ui.composables.BankIcon
import net.codinux.banking.ui.config.DI
import net.codinux.banking.ui.config.Internationalization
import net.codinux.banking.ui.forms.OutlinedTextField
import net.codinux.banking.ui.forms.Select
import net.codinux.banking.ui.model.TanChallengeReceived
import net.codinux.banking.ui.model.error.ErroneousAction
import net.codinux.banking.ui.service.createImageBitmap
import net.codinux.log.Log
import org.jetbrains.compose.resources.imageResource
@ -50,12 +53,29 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
var enteredTan by remember { mutableStateOf("") }
challenge.addTanExpiredCallback {
val erroneousAction = when (challenge.forAction) {
ActionRequiringTan.GetTransactions -> ErroneousAction.UpdateAccountTransactions
ActionRequiringTan.TransferMoney -> ErroneousAction.TransferMoney
else -> ErroneousAction.AddAccount
}
DI.uiState.applicationErrorOccurred(erroneousAction, "TAN ist abgelaufen und kann nicht mehr eingegeben werden")
onDismiss()
}
if (isDecoupledMethod) {
challenge.addUserApprovedDecoupledTanCallback {
onDismiss()
}
}
fun dismiss() {
tanChallengeReceived.callback(EnterTanResult(null))
onDismiss()
}
fun confirmCalled() {
if (enteredTan.length > 2) {
tanChallengeReceived.callback(EnterTanResult(enteredTan))