From 8cac7b52ee44bb5a3c1bca3f4fd88b43f59e3d2c Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 14 Sep 2020 00:10:13 +0200 Subject: [PATCH] Fixed that for a new account may an old (undeleted) file with may an old, wrong password got used --- .../net/dankito/banking/fints4kBankingClient.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt index 2e99f5d7..800b0784 100644 --- a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt +++ b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt @@ -159,8 +159,19 @@ open class fints4kBankingClient( protected open fun restoreDataOrMapFromUiModel(customer: TypedCustomer): BankData { - return restoreData(customer) ?: - BankData(customer.bankCode, customer.customerId, customer.password, customer.finTsServerAddress, customer.bic, customer.bankName) + if (isNewAccount(customer)) { + return mapToBankData(customer) + } + + return restoreData(customer) ?: mapToBankData(customer) + } + + protected open fun isNewAccount(customer: TypedCustomer): Boolean { + return customer.accounts.isEmpty() + } + + protected open fun mapToBankData(customer: TypedCustomer): BankData { + return BankData(customer.bankCode, customer.customerId, customer.password, customer.finTsServerAddress, customer.bic, customer.bankName) } protected open fun restoreData(customer: TypedCustomer): BankData? {