Fixed `AuthSystemDefault` through repo `machine/checkToken` to return MACHINE ID (as for WAREHOUSE/ADMIN session data) + fixed code

This commit is contained in:
xdrm-brackets 2017-02-21 15:55:40 +01:00
parent b170c98187
commit 91c64751ca
3 changed files with 14 additions and 26 deletions

View File

@ -142,13 +142,12 @@
$checkBranch = new Repo('machine/checkToken', [ $_SESSION['WAREHOUSE']['id'], $_SESSION['AUTH'][1], $_SESSION['AUTH'][2] ]);
/* (1) Si le token n'est pas valide, on retourne une erreur */
if( $checkBranch->answer() == false )
if( $checkBranch->answer() === false )
return false;
/* (2) On met à jour les informations de l'administrateur */
$_SESSION['SATS'] = [
'id' => (int) $checkBranch->answer()['id_machine'],
'name' => $checkBranch->answer()['name']
'id' => (int) $checkBranch->answer()
];

View File

@ -614,17 +614,6 @@
@ -672,18 +661,15 @@
'id_machine' => $_SESSION['SATS']['id']
]);
var_dump('req', $log_req->error->get());
// {2} Manage error //
if( $log_req->error->get() != Err::Success )
continue;
// {3} Process + get response //
// {2} Process + get response //
$log_res = $log_req->dispatch();
var_dump('res', $log_res->error->get());
// {4} Register if success //
if( $log_res->error->get() == Err::Success )
$fetched['history']++;
// {3} Exit on failure //
if( $log_res->error->get() != Err::Success )
break;
// {4} Register count if success //
$fetched['history']++;
}
}

View File

@ -373,7 +373,7 @@
* @token<String> Token de synchronisation
* @newToken<String> Nouveau token de synchronisation (optionnel, uniquement quand on arrive à la fin du cycle de la hashChain)
*
* @return status<Boolean> VRAI si le token est correct, sinon FALSE
* @return machine_id<int> ID de la machine si correct, sinon FALSE
*
*/
public static function checkToken($id_warehouse, $token, $newToken=null){
@ -400,7 +400,10 @@
/* [3] On retourne que tout s'est bien déroulé
=========================================================*/
return $updated;
if( !$updated )
return false;
return $byToken['id_machine'];
}