-rw-r--r-- | backend/php/src/index.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/backend/php/src/index.php b/backend/php/src/index.php index eb3d75a..58c10a9 100644 --- a/backend/php/src/index.php +++ b/backend/php/src/index.php @@ -532,213 +532,216 @@ error_log("message"); for ($i=0; $i<$c; $i++) { $recordList = $user->GetRecordList(array(array("reference", "=", $recordParameterList[$i]["record"]["reference"]))); $currentRecord = $recordList[0]; $currentRecordVersions = $currentRecord->GetRecordversionList(); $currentVersion = $currentRecordVersions[0]; updateRecordData($recordParameterList[$i], $currentRecord, $currentVersion); $currentRecord->Save(); $currentVersion->Save(); } $result["lock"] = $user->lock; $result["result"] = "done"; //============================================================= } else if ($message == "deleteRecords") { //{ // "message":"deleteRecords", // "srpSharedSecret":"4a64982f7ee366954ec50b9efea62a902a097ef111410c2aa7c4d5343bd1cdd1", // "parameters":{ // "recordReferences":["46494c81d10b80ab190d41e6806ef63869cfcc7a0ab8fe98cc3f93de4729bb9a"], // "user":{ // "header":"{\"rec...rsion\":\"0.1\"}", // "statistics":"44kOOda0xYZjbcugJBdagBQx", // "version":"0.3", // "lock":"----" // } // } //} $user = new user(); $user = $user->Get($_SESSION["userId"]); $recordReferenceList = $parameters["parameters"]["recordReferences"]; $recordList = array(); $c = count($recordReferenceList); for ($i=0; $i<$c; $i++) { array_push($recordList, array("reference", "=", $recordReferenceList[$i])); } $record = new record(); $record->DeleteList($recordList, true); updateUserData($parameters["parameters"]["user"], $user); $user->Save(); $result["recordList"] = $recordList; $result["lock"] = $user->lock; $result["result"] = "done"; //============================================================= } else if ($message == "deleteUser") { //{"message":"deleteUser", "srpSharedSecret":"e8e4ca6544dca49c95b3647d8358ad54c317048b74d2ac187ac25f719c9bac58", "parameters":{}} $user = new user(); $user->Get($_SESSION["userId"]); $user->Delete(true); $result["result"] = "ok"; //============================================================= } else if ($message == "addNewOneTimePassword") { //{ // "message":"addNewOneTimePassword", // "srpSharedSecret":"96fee4af06c09ce954fe7a9f87970e943449186bebf70bac0af1d6ebb818dabb", // "parameters":{ // "user":{ // "header":"{\"records\":{\"index\":{\"419ea6....rsion\":\"0.1\"}", // "statistics":"rrlwNbDt83rpWT4S72upiVsC", // "version":"0.3", // "lock":"----" // }, // "oneTimePassword":{ // "reference":"29e26f3a2aae61fe5cf58c45296c6df4f3dceafe067ea550b455be345f44123c", // "key":"afb848208758361a96a298b9db08995cf036011747809357a90645bc93fdfa03", // "keyChecksum":"d1599ae443b5a566bfd93c0aeec4c81b42c0506ee09874dae050449580bb3486", // "data":"hsyY8DHksgR52x6c4j7XAtIUeY.....dxsr3XWt7CbGg==", // "version":"0.3" // } // } //} fixOTPStatusTable(); $user = new user(); $user = $user->Get($_SESSION["userId"]); $otp = new onetimepassword(); updateOTP($parameters["parameters"]["oneTimePassword"], $otp, "ACTIVE"); $user->AddOnetimepassword($otp); updateUserData($parameters["parameters"]["user"], $user); $user->Save(); $result["lock"] = $user->lock; $result["result"] = "done"; //============================================================= } else if ($message == "updateOneTimePasswords") { //{ // "message":"updateOneTimePasswords", // "srpSharedSecret":"c78f8ed099ea421f4dd0a4e02dbaf1f7da925f0088188d99399874ff064a3d27", // "parameters":{ // "user":{ // "header":"{\"reco...sion\":\"0.1\"}", // "statistics":"UeRq75RZHzDC7elzrh/+OB5d", // "version":"0.3", // "lock":"----" // }, // "oneTimePasswords":["f5f44c232f239efe48ab81a6236deea1a840d52946f7d4d782dad52b4c5359ce"] // } //} $user = new user(); $user = $user->Get($_SESSION["userId"]); $validOtpReferences = $parameters["parameters"]["oneTimePasswords"]; $otpList = $user->GetOnetimepasswordList(); $c = count($otpList); for ($i=0; $i<$c; $i++) { $currentOtp = $otpList[$i]; if (arrayContainsValue($validOtpReferences, $currentOtp->reference) == false) { $currentOtp->Delete(); } } updateUserData($parameters["parameters"]["user"], $user); $user->Save(); $result["result"] = $user->lock; //============================================================= } else if ($message == "getOneTimePasswordsDetails") { //============================================================= } else if ($message == "getLoginHistory") { $result["result"] = array(); //============================================================= } else if ($message == "upgradeUserCredentials") { //{ // "message":"upgradeUserCredentials", // "srpSharedSecret":"f1c25322e1478c8fb26063e9eef2f6fc25e0460065a31cb718f80bcff8f8a735", // "parameters":{ // "user":{ // "header":"{\"reco...sion\":\"0.1\"}", // "statistics":"s72Xva+w7CLgH+ihwqwXUbyu", // "version":"0.3", // "lock":"----" // }, // "credentials":{ // "C":"57d15a8afbc1ae08103bd991d387ddfd8d26824276476fe709d754f098b6c26d", // "s":"d6735fc0486f391c4f3c947928f9e61a2418e7bed2bc9b25bb43f93acc52f636", // "v":"540c2ebbf941a481b6b2c9026c07fb46e8202e4408ed96864a696deb622baece", // "version":"0.2" // }, // "oneTimePasswords":{ // "923cdc61c4b877b263236124c44d69b459d240453a461cce8ddf7518b423ca94": "1HD6Ta0xsifEDhDwE....9WDK6tvrS6w==", // "fb1573cb9497652a81688a099a524fb116e604c6fbc191cf33406eb8438efa5f": "CocN0cSxLmMRdgNF9....o3xhGUEY68Q==" // } // } //} $user = new user(); $user->Get($_SESSION["userId"]); $otp = new onetimepassword(); updateUserCredentials($parameters["parameters"]["credentials"], $user); updateUserData($parameters["parameters"]["user"], $user); $otpList = $parameters["parameters"]["oneTimePasswords"]; foreach($otpList as $otpReference=>$otpData) { $otpList = $otp->GetList(array(array("reference", "=", $otpReference))); $currentOtp = $otpList[0]; $currentOtp->data = $otpData; $currentOtp->Save(); } $user->Save(); $result["lock"] = $user->lock; $result["result"] = "done"; //============================================================= } else if ($message == "echo") { $result["result"] = $parameters; } //============================================================= - } else { + } else if (isset($_SESSION['K'])) { $result["error"] = "Wrong shared secret!"; + } else { + $result["result"] = "EXCEPTION"; + $result["message"] = "Trying to communicate without an active connection"; } break; case "logout": error_log("logout"); session_destroy(); break; default: error_log("default"); $result["result"] = $parameters; break; } session_write_close(); echo(json_encode($result)); error_log("result: ".json_encode($result)); -?>
\ No newline at end of file +?> |