From a0e7fe0534493fe16af22f88e35a65a677fde008 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 13 May 2020 20:33:31 +0200 Subject: [PATCH] Implemented setting selected TAN procedure without asking user if there is only one allowed TAN procedure --- .../kotlin/net/dankito/fints/FinTsClient.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 7be02dd2..6a323c85 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -172,8 +172,13 @@ open class FinTsClient @JvmOverloads constructor( var didOverwriteUserUnselectedTanProcedure = false if (customer.isTanProcedureSelected == false && customer.supportedTanProcedures.isNotEmpty()) { - didOverwriteUserUnselectedTanProcedure = true - customer.selectedTanProcedure = customer.supportedTanProcedures.first() // TODO: check if user has only one TAN procedure -> set it and we're done + if (customer.supportedTanProcedures.size == 1) { // user has only one TAN procedure -> set it and we're done + customer.selectedTanProcedure = customer.supportedTanProcedures.first() + } + else { + didOverwriteUserUnselectedTanProcedure = true + customer.selectedTanProcedure = customer.supportedTanProcedures.first() + } } @@ -501,9 +506,14 @@ open class FinTsClient @JvmOverloads constructor( return Response(false, noTanProcedureSelected = true) } - // we know user's supported tan procedures, now ask user which one to select - callback.askUserForTanProcedure(customer.supportedTanProcedures, selectSuggestedTanProcedure(customer))?.let { - customer.selectedTanProcedure = it + if (customer.supportedTanProcedures.size == 1) { // user has only one TAN procedure -> set it and we're done + customer.selectedTanProcedure = customer.supportedTanProcedures.first() + } + else { + // we know user's supported tan procedures, now ask user which one to select + callback.askUserForTanProcedure(customer.supportedTanProcedures, selectSuggestedTanProcedure(customer))?.let { + customer.selectedTanProcedure = it + } } }