mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-21 04:07:44 +02:00
Use the totp period from Uri instead of hard coded value
This commit is contained in:
parent
ad09f233db
commit
9fa4308e24
@ -26,11 +26,14 @@ class TimedTOTP
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentPosition = time();
|
$currentPosition = time();
|
||||||
$PeriodCount = floor($currentPosition / 30); //nombre de période de 30s depuis T0
|
$PeriodCount = floor($currentPosition / $otp->getPeriod()); //nombre de période de x s depuis T0 (x=30 par défaut)
|
||||||
$currentPeriodStartAt = $PeriodCount * 30;
|
$currentPeriodStartAt = $PeriodCount * $otp->getPeriod();
|
||||||
$currentPeriodendAt = $currentPeriodStartAt + 30;
|
|
||||||
$positionInCurrentPeriod = $currentPosition - $currentPeriodStartAt;
|
$positionInCurrentPeriod = $currentPosition - $currentPeriodStartAt;
|
||||||
|
|
||||||
|
// for memo :
|
||||||
|
// $nextOtpAt = ($PeriodCount+1)*$period
|
||||||
|
// $remainingTime = $nextOtpAt - time()
|
||||||
|
|
||||||
$totp = [
|
$totp = [
|
||||||
'totp' => $otp->now(),
|
'totp' => $otp->now(),
|
||||||
'position' => $positionInCurrentPeriod
|
'position' => $positionInCurrentPeriod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user