Use correct time to find TOTP secret (#1387)
This commit is contained in:
parent
7710ca9024
commit
7a532302e3
1 changed files with 3 additions and 2 deletions
|
@ -14,6 +14,7 @@ import dev.msfjarvis.aps.util.totp.Otp
|
||||||
import dev.msfjarvis.aps.util.totp.TotpFinder
|
import dev.msfjarvis.aps.util.totp.TotpFinder
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
import kotlin.time.ExperimentalTime
|
import kotlin.time.ExperimentalTime
|
||||||
|
import kotlin.time.seconds
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
@ -83,10 +84,10 @@ constructor(
|
||||||
scope.launch {
|
scope.launch {
|
||||||
updateTotp(clock.millis())
|
updateTotp(clock.millis())
|
||||||
val remainingTime = totpPeriod - (System.currentTimeMillis() % totpPeriod)
|
val remainingTime = totpPeriod - (System.currentTimeMillis() % totpPeriod)
|
||||||
delay(remainingTime)
|
delay(remainingTime.seconds)
|
||||||
repeat(Int.MAX_VALUE) {
|
repeat(Int.MAX_VALUE) {
|
||||||
updateTotp(clock.millis())
|
updateTotp(clock.millis())
|
||||||
delay(totpPeriod)
|
delay(totpPeriod.seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue