diff --git a/test/client/background.php b/test/client/background.php index f8d05c6..f7e1811 100644 --- a/test/client/background.php +++ b/test/client/background.php @@ -53,9 +53,14 @@ '@data' => json_encode( $_SESSION['history'] ), '@renew' => sessionManager::secure_hash( $_COOKIE['mac_password'], 10) ]); + $parsedResponse = json_decode( $response, true ); - $_COOKIE['mac_count'] = 9; - setcookie('mac_count', $_COOKIE['mac_count'], time()+3600*24*365, '/'); + + // On change les données locales uniquement si on a une réponse positive + if( $parsedResponse['ModuleError'] == 0 ){ + $_COOKIE['mac_count'] = 9; + setcookie('mac_count', $_COOKIE['mac_count'], time()+3600*24*365, '/'); + } }else{ @@ -64,17 +69,20 @@ '@token' => $token, '@data' => json_encode( $_SESSION['history'] ) ]); + $parsedResponse = json_decode( $response, true ); - $_COOKIE['mac_count']--; - setcookie('mac_count', $_COOKIE['mac_count'], time()+3600*24*365, '/'); + + // On change les données locales uniquement si on a une réponse positive + if( $parsedResponse['ModuleError'] == 0 ){ + $_COOKIE['mac_count']--; + setcookie('mac_count', $_COOKIE['mac_count'], time()+3600*24*365, '/'); + } } - $parsedResponse = json_decode( $response, true ); $toReturn = [ 'response' => $parsedResponse, - 'pwd' => $_COOKIE['mac_password'], 'count' => $_COOKIE['mac_count'], 'token' => $token, 'status' => $parsedResponse['ModuleError'], diff --git a/test/client/interface.php b/test/client/interface.php index 80fe77d..9042584 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -4,7 +4,7 @@ $_SESSION['history'] = []; if( !isset($_COOKIE['mac_password']) || !isset($_COOKIE['mac_count']) ){ - $_COOKIE['mac_count'] = 9; + $_COOKIE['mac_count'] = 10; $_COOKIE['mac_password'] = 'macPassword'; setcookie('mac_count', $_COOKIE['mac_count'], time()+3600*24*365, '/'); @@ -25,156 +25,158 @@ + + +
-