From e75b599b71951cd92b023de2a81bbbed0a965b8f Mon Sep 17 00:00:00 2001 From: Piotr Pawlow Date: Sun, 19 Mar 2017 18:20:56 +0100 Subject: Move delay to between getting verification result, and checking the result. --- auth.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'auth.php') diff --git a/auth.php b/auth.php index 7e839c9..ccb2859 100644 --- a/auth.php +++ b/auth.php @@ -23,14 +23,15 @@ foreach($config_default as $k => $v) if (!isset($config->{$k})) $config->{$k} = if (!preg_match('/^[A-Z2-7]+$/i', $config->secret)) die("Base32 encoded secret required\n"); $totp = new TOTP(null, $config->secret, $config->period, $config->digest, $config->digits); while(true) { - sleep($config->delay); echo "Czas serwera: "; $now = new DateTime(); echo $now->format('Y-m-d H:i:s'); echo "\n"; echo "Podaj kod:\n"; $code = readline(); - if ($totp->verify($code, null, $config->window)) { + $verify_result = $totp->verify($code, null, $config->window); + sleep($config->delay); + if ($verify_result) { break; } else { echo "Zły kod\n"; -- cgit v1.2.3