-rw-r--r-- | backend/php/src/index.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/backend/php/src/index.php b/backend/php/src/index.php index 58c10a9..3d23e7a 100644 --- a/backend/php/src/index.php +++ b/backend/php/src/index.php | |||
@@ -330,96 +330,103 @@ error_log("oneTimePassword"); | |||
330 | //"parameters":{ | 330 | //"parameters":{ |
331 | // "oneTimePasswordKey":"06dfa7f428081f8b2af98b0895e14e18af90b0ef2ff32828e55cc2ac6b24d29b", | 331 | // "oneTimePasswordKey":"06dfa7f428081f8b2af98b0895e14e18af90b0ef2ff32828e55cc2ac6b24d29b", |
332 | // "oneTimePasswordKeyChecksum":"60bcba3f72e56f6bb3f0ff88509b9a0e5ec730dfa71daa4c1e892dbd1b0c360d" | 332 | // "oneTimePasswordKeyChecksum":"60bcba3f72e56f6bb3f0ff88509b9a0e5ec730dfa71daa4c1e892dbd1b0c360d" |
333 | //} | 333 | //} |
334 | //} | 334 | //} |
335 | $otp = new onetimepassword(); | 335 | $otp = new onetimepassword(); |
336 | $otpList = $otp->GetList(array(array("key", "=", $parameters["parameters"]["oneTimePasswordKey"]))); | 336 | $otpList = $otp->GetList(array(array("key", "=", $parameters["parameters"]["oneTimePasswordKey"]))); |
337 | 337 | ||
338 | if (count($otpList) == 1) { | 338 | if (count($otpList) == 1) { |
339 | $currentOtp = $otpList[0]; | 339 | $currentOtp = $otpList[0]; |
340 | 340 | ||
341 | if ($currentOtp->GetOnetimepasswordstatus()->code == "ACTIVE") { | 341 | if ($currentOtp->GetOnetimepasswordstatus()->code == "ACTIVE") { |
342 | if ($currentOtp->key_checksum == $parameters["parameters"]["oneTimePasswordKeyChecksum"]) { | 342 | if ($currentOtp->key_checksum == $parameters["parameters"]["oneTimePasswordKeyChecksum"]) { |
343 | $_SESSION["userId"] = $currentOtp->GetUser()->userId; | 343 | $_SESSION["userId"] = $currentOtp->GetUser()->userId; |
344 | $_SESSION["otpId"]= $currentOtp->onetimepasswordId; | 344 | $_SESSION["otpId"]= $currentOtp->onetimepasswordId; |
345 | 345 | ||
346 | $result["data"] = $currentOtp->data; | 346 | $result["data"] = $currentOtp->data; |
347 | $result["version"] = $currentOtp->version; | 347 | $result["version"] = $currentOtp->version; |
348 | 348 | ||
349 | resetOTP($currentOtp, "REQUESTED"); | 349 | resetOTP($currentOtp, "REQUESTED"); |
350 | } else { | 350 | } else { |
351 | resetOTP($currentOtp, "DISABLED"); | 351 | resetOTP($currentOtp, "DISABLED"); |
352 | throw new Exception("The requested One Time Password has been disabled, due to a wrong keyChecksum"); | 352 | throw new Exception("The requested One Time Password has been disabled, due to a wrong keyChecksum"); |
353 | } | 353 | } |
354 | } else { | 354 | } else { |
355 | throw new Exception("The requested One Time Password was not active"); | 355 | throw new Exception("The requested One Time Password was not active"); |
356 | } | 356 | } |
357 | } else { | 357 | } else { |
358 | throw new Exception("The requested One Time Password has not been found"); | 358 | throw new Exception("The requested One Time Password has not been found"); |
359 | } | 359 | } |
360 | 360 | ||
361 | //============================================================= | 361 | //============================================================= |
362 | } | 362 | } |
363 | 363 | ||
364 | break; | 364 | break; |
365 | 365 | ||
366 | case "message": | 366 | case "message": |
367 | error_log("message"); | 367 | error_log("message"); |
368 | if ($parameters["srpSharedSecret"] == $_SESSION["K"]) { | 368 | if ($parameters["srpSharedSecret"] == $_SESSION["K"]) { |
369 | $message = $parameters["message"]; | 369 | $message = $parameters["message"]; |
370 | 370 | ||
371 | //============================================================= | 371 | //============================================================= |
372 | if ($message == "getUserDetails") { | 372 | if ($message == "getUserDetails") { |
373 | //{"message":"getUserDetails", "srpSharedSecret":"f18e5cf7c3a83b67d4db9444af813ee48c13daf4f8f6635397d593e52ba89a08", "parameters":{}} | 373 | //{"message":"getUserDetails", "srpSharedSecret":"f18e5cf7c3a83b67d4db9444af813ee48c13daf4f8f6635397d593e52ba89a08", "parameters":{}} |
374 | $user = new user(); | 374 | $user = new user(); |
375 | $user = $user->Get($_SESSION["userId"]); | 375 | $user = $user->Get($_SESSION["userId"]); |
376 | 376 | ||
377 | $result["header"] = $user->header; | 377 | $result["header"] = $user->header; |
378 | $records = $user->GetRecordList(); | ||
379 | foreach ($records as $record) | ||
380 | { | ||
381 | $recordStats["updateDate"] = $record->update_date; | ||
382 | $recordsStats[$record->reference] = $recordStats; | ||
383 | } | ||
384 | $result["recordsStats"] = $recordsStats; | ||
378 | $result["statistics"] =$user->statistics; | 385 | $result["statistics"] =$user->statistics; |
379 | $result["version"] =$user->version; | 386 | $result["version"] =$user->version; |
380 | 387 | ||
381 | //============================================================= | 388 | //============================================================= |
382 | } else if ($message == "addNewRecords") { | 389 | } else if ($message == "addNewRecords") { |
383 | /* | 390 | /* |
384 | //{ | 391 | //{ |
385 | //"message":"addNewRecords", | 392 | //"message":"addNewRecords", |
386 | //"srpSharedSecret":"b58fdf62acebbcb67f63d28c0437f166069f45690c648cd4376a792ae7a325f7", | 393 | //"srpSharedSecret":"b58fdf62acebbcb67f63d28c0437f166069f45690c648cd4376a792ae7a325f7", |
387 | //"parameters":{ | 394 | //"parameters":{ |
388 | // "records":[ | 395 | // "records":[ |
389 | // { | 396 | // { |
390 | // "record":{ | 397 | // "record":{ |
391 | // "reference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610", | 398 | // "reference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610", |
392 | // "data":"OBSGtcb6blXq/xaYG.....4EqlQqgAvITN", | 399 | // "data":"OBSGtcb6blXq/xaYG.....4EqlQqgAvITN", |
393 | // "version":"0.3" | 400 | // "version":"0.3" |
394 | // }, | 401 | // }, |
395 | // "currentRecordVersion":{ | 402 | // "currentRecordVersion":{ |
396 | // "reference":"83ad301525c18f2afd72b6ac82c0a713382e1ef70ac69935ca7e2869dd4ff980", | 403 | // "reference":"83ad301525c18f2afd72b6ac82c0a713382e1ef70ac69935ca7e2869dd4ff980", |
397 | // "recordReference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610", | 404 | // "recordReference":"fda703707fee1fff42443124cd0e705f5bea0ac601758d81b2e832705339a610", |
398 | // "data":"NXJ5jiZhkd0CMiwwntAq....1TjjF+SGfE=", | 405 | // "data":"NXJ5jiZhkd0CMiwwntAq....1TjjF+SGfE=", |
399 | // "version":"0.3", | 406 | // "version":"0.3", |
400 | // "previousVersion":"3e174a86afc322271d8af28bc062b0f1bfd7344fad01212cd08b2757c4b199c4", | 407 | // "previousVersion":"3e174a86afc322271d8af28bc062b0f1bfd7344fad01212cd08b2757c4b199c4", |
401 | // "previousVersionKey":"kozaaGCzXWr71LbOKu6Z3nz520V..5U85tSBvb+u44twttv54Kw==" | 408 | // "previousVersionKey":"kozaaGCzXWr71LbOKu6Z3nz520V..5U85tSBvb+u44twttv54Kw==" |
402 | // } | 409 | // } |
403 | // } | 410 | // } |
404 | // ], | 411 | // ], |
405 | // "user":{ | 412 | // "user":{ |
406 | // "header":"{\"reco...ersion\":\"0.1\"}", | 413 | // "header":"{\"reco...ersion\":\"0.1\"}", |
407 | // "statistics":"rKI6nR6iqggygQJ3SQ58bFUX", | 414 | // "statistics":"rKI6nR6iqggygQJ3SQ58bFUX", |
408 | // "version":"0.3", | 415 | // "version":"0.3", |
409 | // "lock":"----" | 416 | // "lock":"----" |
410 | // } | 417 | // } |
411 | //} | 418 | //} |
412 | //} | 419 | //} |
413 | */ | 420 | */ |
414 | $user = new user(); | 421 | $user = new user(); |
415 | $record = new record(); | 422 | $record = new record(); |
416 | $recordVersion = new recordversion(); | 423 | $recordVersion = new recordversion(); |
417 | 424 | ||
418 | $user = $user->Get($_SESSION["userId"]); | 425 | $user = $user->Get($_SESSION["userId"]); |
419 | updateUserData($parameters["parameters"]["user"], $user); | 426 | updateUserData($parameters["parameters"]["user"], $user); |
420 | 427 | ||
421 | $recordParameterList = $parameters["parameters"]["records"]; | 428 | $recordParameterList = $parameters["parameters"]["records"]; |
422 | $c = count($recordParameterList); | 429 | $c = count($recordParameterList); |
423 | for ($i=0; $i<$c; $i++) { | 430 | for ($i=0; $i<$c; $i++) { |
424 | updateRecordData($recordParameterList[$i], $record, $recordVersion); | 431 | updateRecordData($recordParameterList[$i], $record, $recordVersion); |
425 | 432 | ||