From 9fa4308e24aec9cd59e362462ed11e983cce8a55 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 10 Jan 2020 23:10:59 +0100 Subject: [PATCH] Use the totp period from Uri instead of hard coded value --- app/Classes/TimedTOTP.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Classes/TimedTOTP.php b/app/Classes/TimedTOTP.php index 4fcb48f2..e09c14fa 100644 --- a/app/Classes/TimedTOTP.php +++ b/app/Classes/TimedTOTP.php @@ -26,11 +26,14 @@ class TimedTOTP } $currentPosition = time(); - $PeriodCount = floor($currentPosition / 30); //nombre de période de 30s depuis T0 - $currentPeriodStartAt = $PeriodCount * 30; - $currentPeriodendAt = $currentPeriodStartAt + 30; + $PeriodCount = floor($currentPosition / $otp->getPeriod()); //nombre de période de x s depuis T0 (x=30 par défaut) + $currentPeriodStartAt = $PeriodCount * $otp->getPeriod(); $positionInCurrentPeriod = $currentPosition - $currentPeriodStartAt; + // for memo : + // $nextOtpAt = ($PeriodCount+1)*$period + // $remainingTime = $nextOtpAt - time() + $totp = [ 'totp' => $otp->now(), 'position' => $positionInCurrentPeriod