diff --git a/build/database/repo/machine.php b/build/database/repo/machine.php index ceb5a7f..74765a1 100755 --- a/build/database/repo/machine.php +++ b/build/database/repo/machine.php @@ -301,11 +301,25 @@ ->whereUnlockCode($unlock_code) ->fetch(); - var_dump($machine); - /* (2) On vérifie si on a bien le bon code */ if( $machine === false ) return false; + + + /* [2] Si le code est bon, on le supprime et on met le token + =========================================================*/ + /* (1) Update (edit) machine */ + $updated = Table::get('machine') + ->whereId($id_machine) + ->whereIdWarehouse($id_warehouse) + ->edit([ + 'unlock_code' => null, + 'token' => $first_token + ]); + + /* (2) Manage edition error */ + return $updated; + } @@ -322,7 +336,7 @@ public static function checkToken($id_warehouse, $token, $newToken=null){ /* [1] On vérifie le token =========================================================*/ - $hash = secure_hash($token); + $hash = secure_hash($token, ''); $byToken = self::getByToken($id_warehouse, $hash);