fix calculation of touch TOTP

This commit is contained in:
Adam Velebil 2022-04-05 13:15:08 +02:00
parent d8916161f6
commit ada86d7dad
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
2 changed files with 4 additions and 4 deletions

View File

@ -236,7 +236,7 @@ class MainViewModel : ViewModel() {
private fun calculateCode(
session: OathSession,
credential: Credential,
timestamp: Long = 0
timestamp: Long
) =
if (credential.isSteamCredential()) {
session.calculateSteamCode(credential, timestamp)
@ -276,7 +276,7 @@ class MainViewModel : ViewModel() {
val code =
if (credentialData.oathType == OathType.TOTP && !requireTouch) {
// recalculate the code
calculateCode(session, credential)
calculateCode(session, credential, System.currentTimeMillis())
} else null
val jsonResult = Pair<Credential, Code?>(credential, code)
@ -407,7 +407,7 @@ class MainViewModel : ViewModel() {
val credential = getOathCredential(session, credentialId)
val resultJson = calculateCode(session, credential)
val resultJson = calculateCode(session, credential, System.currentTimeMillis())
.toJson()
.toString()

View File

@ -21,7 +21,7 @@ fun Credential.isSteamCredential(): Boolean =
*/
fun OathSession.calculateSteamCode(
credential: Credential,
timestamp: Long = 0,
timestamp: Long,
): Code {
val timeSlotMs = 30_000
if (!credential.isSteamCredential()) {