diff --git a/api/index.php b/api/index.php index 1451af9..0d93efa 100644 --- a/api/index.php +++ b/api/index.php @@ -512,6 +512,7 @@ switch($PARAM_1) } else { + http_response_code(409); print json_encode([ "status" => "error", "error" => "company_already_registered", @@ -566,6 +567,7 @@ switch($PARAM_1) //echo "
".print_r($arFields, true).""; //echo $error; + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_payload", @@ -577,6 +579,7 @@ switch($PARAM_1) } else { + http_response_code(409); print json_encode([ "status" => "error", "error" => "company_already_registered", @@ -675,6 +678,7 @@ switch($PARAM_1) { //new company + http_response_code(404); print json_encode([ "status" => "error", "error" => "no_company_for_update", @@ -728,6 +732,7 @@ switch($PARAM_1) } else { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_payload", @@ -741,6 +746,7 @@ switch($PARAM_1) { //no company + http_response_code(404); print json_encode([ "status" => "error", "error" => "no_company_for_update", @@ -791,6 +797,7 @@ switch($PARAM_1) { if(!in_array($auth['acc_number'], $existed_accounts)) { + http_response_code(401); print json_encode([ "status" => "error", "error" => "access_denied", @@ -836,6 +843,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "unknown account", @@ -845,6 +853,7 @@ switch($PARAM_1) } catch(\Exception $e) { + http_response_code(401); print json_encode([ "status" => "error", "error" => "wrong_jwt", @@ -855,6 +864,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -891,6 +901,7 @@ switch($PARAM_1) default: { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_user_uri", @@ -930,6 +941,7 @@ switch($PARAM_1) } catch(\Exception $e) { + http_response_code(401); print json_encode([ "status" => "error", "error" => "wrong_jwt", @@ -940,6 +952,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -1054,6 +1067,7 @@ switch($PARAM_1) } catch(\Exception $e) { + http_response_code(401); print json_encode([ "status" => "error", "error" => "wrong_jwt", @@ -1064,6 +1078,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -1141,6 +1156,7 @@ switch($PARAM_1) } catch(\Exception $e) { + http_response_code(401); print json_encode([ "status" => "error", "error" => "wrong_jwt", @@ -1151,6 +1167,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -1163,6 +1180,7 @@ switch($PARAM_1) default: { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_admin_uri", @@ -2600,24 +2618,37 @@ switch($PARAM_1) if(is_array($ar_user)) { - if(SEND_EMAIL_PASSWORD_RECOVERY_CODE) + if(!empty($REQ['code'])) { - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "USER_PASSWORD_RECOVERY_CODE", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "CODE" => $REQ['code'], - ) + if(SEND_EMAIL_PASSWORD_RECOVERY_CODE) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_PASSWORD_RECOVERY_CODE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "CODE" => $REQ['code'], + ) + ]); + } + + print json_encode([ + "status" => "success", ]); } - - print json_encode([ - "status" => "success", - ]); + else + { + http_response_code(400); + print json_encode([ + "status" => "error", + "error" => "empty_code", + "message" => "Empty code", + ]); + } } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "wrong_email", @@ -2627,6 +2658,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -2655,6 +2687,7 @@ switch($PARAM_1) if($user->LAST_ERROR) { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_payload", @@ -2670,6 +2703,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "wrong_email", @@ -2679,6 +2713,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -2718,6 +2753,7 @@ switch($PARAM_1) if($user->LAST_ERROR) { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_payload", @@ -2725,7 +2761,7 @@ switch($PARAM_1) ]); } else - { + { print json_encode([ "status" => "success", ]); @@ -2733,6 +2769,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "unknow_user", @@ -2742,6 +2779,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "wrong_email", @@ -2751,6 +2789,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -2792,6 +2831,7 @@ switch($PARAM_1) if($user->LAST_ERROR) { + http_response_code(400); print json_encode([ "status" => "error", "error" => "wrong_payload", @@ -2807,6 +2847,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "wrong_company", @@ -2816,6 +2857,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "wrong_email", @@ -2825,6 +2867,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source", @@ -2880,6 +2923,7 @@ switch($PARAM_1) } else { + http_response_code(401); print json_encode([ "status" => "error", "error" => "wrong_credentials", @@ -2934,6 +2978,7 @@ switch($PARAM_1) } else { + http_response_code(404); print json_encode([ "status" => "error", "error" => "unknown_user", @@ -2943,6 +2988,7 @@ switch($PARAM_1) } else { + http_response_code(403); print json_encode([ "status" => "error", "error" => "wrong_source",