Terminate waiting for TAN input after a timeout
This commit is contained in:
parent
113b817627
commit
da2bf8d469
|
@ -3,6 +3,7 @@ package net.codinux.banking.fints
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.datetime.Instant
|
||||
import kotlinx.datetime.LocalDate
|
||||
import net.codinux.banking.fints.extensions.*
|
||||
import net.codinux.log.logger
|
||||
import net.codinux.banking.fints.messages.MessageBuilder
|
||||
import net.codinux.banking.fints.messages.MessageBuilderResult
|
||||
|
@ -19,9 +20,6 @@ import net.codinux.banking.fints.response.segments.*
|
|||
import net.codinux.banking.fints.tan.FlickerCodeDecoder
|
||||
import net.codinux.banking.fints.tan.TanImageDecoder
|
||||
import net.codinux.banking.fints.util.TanMethodSelector
|
||||
import net.codinux.banking.fints.extensions.minusDays
|
||||
import net.codinux.banking.fints.extensions.todayAtEuropeBerlin
|
||||
import net.codinux.banking.fints.extensions.todayAtSystemDefaultTimeZone
|
||||
import kotlin.math.max
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
|
@ -389,7 +387,14 @@ open class FinTsJobExecutor(
|
|||
while (tanChallenge.isEnteringTanDone == false) {
|
||||
delay(500)
|
||||
|
||||
// TODO: add a timeout of e.g. 30 min
|
||||
// most TANs a valid 5 - 15 minutes. So terminate wait process after that time
|
||||
if (Instant.nowExt() > tanChallenge.timestamp.plusMinutes(15)) {
|
||||
if (tanChallenge.isEnteringTanDone == false) {
|
||||
tanChallenge.userDidNotEnterTan()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
val enteredTanResult = tanChallenge.enterTanResult!!
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package net.codinux.banking.fints.extensions
|
||||
|
||||
import kotlinx.datetime.Clock
|
||||
import kotlinx.datetime.DateTimeUnit
|
||||
import kotlinx.datetime.Instant
|
||||
import kotlinx.datetime.plus
|
||||
|
||||
|
||||
// should actually be named `now()`, but that name is already shadowed by deprecated Instant.Companion.now() method
|
||||
fun Instant.Companion.nowExt(): Instant = Clock.System.now()
|
||||
fun Instant.Companion.nowExt(): Instant = Clock.System.now()
|
||||
|
||||
fun Instant.plusMinutes(minutes: Int) = this.plus(minutes, DateTimeUnit.MINUTE)
|
Loading…
Reference in New Issue