From e648656881ea6af676191cdba0d419a178a65f81 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 19 Feb 2017 12:33:19 +0100 Subject: [PATCH] [Done] init|sync works --- build/database/repo/machine.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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);