+ smscode verify code, path fix

This commit is contained in:
Dominika Liberda 2020-10-05 00:46:42 +02:00
parent 65acdf798d
commit 4b9bdd3bda
6 changed files with 27 additions and 6 deletions

View file

@ -57,4 +57,4 @@ function add_account_authtoken() {
if check_if_user_exists authToken; then
echo ${cookies[sh_session]}:$1 >> secret/authTokens.dat
fi
}
}

View file

@ -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) => {

View file

@ -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
fi

View file

@ -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}}]"
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}}]"

View file

@ -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]}")

View file

@ -29,6 +29,14 @@
<input type="submit">
</form>
</div>
<div class="register-box">
SMS
<form method="POST" class="sms-form">
<label for="code">Code:</label>
<input type="text" name="code">
<input type="submit">
</form>
</div>
<div class="package-list"></div>
</body>
</html>