From 4b9bdd3bdaa41ab982522d52c2f0bce68c43fe88 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Mon, 5 Oct 2020 00:46:42 +0200 Subject: [PATCH] + smscode verify code, path fix --- code/common.sh | 2 +- front/src/index.ts | 13 +++++++++++++ webroot/api/collect.shs | 4 ++-- webroot/api/packages.shs | 4 ++-- webroot/api/smscode.shs | 2 +- webroot/index.html | 8 ++++++++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/code/common.sh b/code/common.sh index d7d1e51..6b5bff5 100644 --- a/code/common.sh +++ b/code/common.sh @@ -57,4 +57,4 @@ function add_account_authtoken() { if check_if_user_exists authToken; then echo ${cookies[sh_session]}:$1 >> secret/authTokens.dat fi -} \ No newline at end of file +} diff --git a/front/src/index.ts b/front/src/index.ts index ae58a75..7e27d44 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -1,7 +1,9 @@ +var phone = 0; const request = (resource: string, data: any) => fetch(`/api/${resource}.shs`, { method: "POST", body: new URLSearchParams(data).toString(), + credentials: "include", }).then((res) => res.json()); window.addEventListener("load", () => { @@ -24,6 +26,17 @@ window.addEventListener("load", () => { password: form.password.value, phone: form.phone.value, }); + phone = form.phone.value; + }); + + const sms = document.querySelector(".sms-form")!; + sms.addEventListener("submit", function (event) { + event.preventDefault(); + const form = event.target as HTMLFormElement; + request("smscode", { + code: form.code.value, + phone: phone, + }); }); request("packages", {}).then((res) => { diff --git a/webroot/api/collect.shs b/webroot/api/collect.shs index b2d9d54..cfde6f6 100755 --- a/webroot/api/collect.shs +++ b/webroot/api/collect.shs @@ -3,7 +3,7 @@ if ! session_verify ${cookies[sh_session]}; then exit 0 fi -source code/common.sh +source "${cfg[namespace]}/code/common.sh" data=$(curl -s -X POST -H "$(get_auth_string)" -H "Content-type: application/json" "https://api-inmobile-pl.easypack24.net/v1/collect/validate" --data '{"geoPoint":{"accuracy":"1","latitude":"'${get_data[lat]}'","longitude":"'${get_data[lon]}'"},"parcel":{"openCode":"'${get_data[openCode]}'","shipmentNumber":"'${get_data[id]}'"}}') @@ -17,4 +17,4 @@ else else jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "emptyPage" fi -fi \ No newline at end of file +fi diff --git a/webroot/api/packages.shs b/webroot/api/packages.shs index d81a139..9848cd0 100644 --- a/webroot/api/packages.shs +++ b/webroot/api/packages.shs @@ -3,9 +3,9 @@ if ! session_verify ${cookies[sh_session]}; then exit 0 fi -source code/common.sh +source "${cfg[namespace]}/code/common.sh" data=$(curl -s -H "$(get_auth_string)" "https://api-inmobile-pl.easypack24.net/v1/parcel?updatedAfter=1970-01-01T00:00:00.000Z") -echo $data | jq -c "[.[] | {shipmentNumber: .shipmentNumber, status: .status, openCode: .openCode, senderName: .senderName, pickupPoint: {name: .pickupPoint.name, status: .pickupPoint.status, location: .pickupPoint.location, description: .pickupPoint.locationDescription, address: .pickupPoint.addressDetails}}]" \ No newline at end of file +echo $data | jq -c "[.[] | {shipmentNumber: .shipmentNumber, status: .status, openCode: .openCode, senderName: .senderName, pickupPoint: {name: .pickupPoint.name, status: .pickupPoint.status, location: .pickupPoint.location, description: .pickupPoint.locationDescription, address: .pickupPoint.addressDetails}}]" diff --git a/webroot/api/smscode.shs b/webroot/api/smscode.shs index da2b2ea..e4e225b 100644 --- a/webroot/api/smscode.shs +++ b/webroot/api/smscode.shs @@ -3,7 +3,7 @@ if ! session_verify ${cookies[sh_session]}; then exit 0 fi -source code/common.sh +source "${cfg[namespace]}/code/common.sh" if [[ ${post_data[phone]} != "" && ${post_data[code]} != "" ]]; then tokens=$(curl -s -X POST -H "Content-type: application/json" --data '{"phoneOS":"Android"}' "https://api-inmobile-pl.easypack24.net/v1/confirmSMSCode/${post_data[phone]}/${post_data[code]}") diff --git a/webroot/index.html b/webroot/index.html index b3957dd..b0b889a 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -29,6 +29,14 @@ +
+ SMS +
+ + + +
+