Added callback to get notified when user approved Decoupled TAN (e.g. to close a dialog)
This commit is contained in:
parent
3f9921a62e
commit
6865f64880
|
@ -21,6 +21,8 @@ open class TanChallenge(
|
||||||
open val isEnteringTanDone: Boolean
|
open val isEnteringTanDone: Boolean
|
||||||
get() = enterTanResult != null
|
get() = enterTanResult != null
|
||||||
|
|
||||||
|
private val userApprovedDecoupledTanCallbacks = mutableListOf<() -> Unit>()
|
||||||
|
|
||||||
|
|
||||||
fun userEnteredTan(enteredTan: String) {
|
fun userEnteredTan(enteredTan: String) {
|
||||||
this.enterTanResult = EnterTanResult(enteredTan.replace(" ", ""))
|
this.enterTanResult = EnterTanResult(enteredTan.replace(" ", ""))
|
||||||
|
@ -28,6 +30,9 @@ open class TanChallenge(
|
||||||
|
|
||||||
internal fun userApprovedDecoupledTan(responseAfterApprovingDecoupledTan: BankResponse) {
|
internal fun userApprovedDecoupledTan(responseAfterApprovingDecoupledTan: BankResponse) {
|
||||||
this.enterTanResult = EnterTanResult(null, true, responseAfterApprovingDecoupledTan)
|
this.enterTanResult = EnterTanResult(null, true, responseAfterApprovingDecoupledTan)
|
||||||
|
|
||||||
|
userApprovedDecoupledTanCallbacks.forEach { it.invoke() }
|
||||||
|
userApprovedDecoupledTanCallbacks.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun userDidNotEnterTan() {
|
fun userDidNotEnterTan() {
|
||||||
|
@ -43,6 +48,15 @@ open class TanChallenge(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun addUserApprovedDecoupledTanCallback(callback: () -> Unit) {
|
||||||
|
if (isEnteringTanDone == false) {
|
||||||
|
this.userApprovedDecoupledTanCallbacks.add(callback)
|
||||||
|
} else if (enterTanResult != null && enterTanResult!!.userApprovedDecoupledTan == true) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "$tanMethod (medium: $tanMediaIdentifier): $messageToShowToUser"
|
return "$tanMethod (medium: $tanMediaIdentifier): $messageToShowToUser"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue