* fixes authToken update problem

master
Dominika Liberda 2021-04-27 23:06:33 +02:00
parent bd394c4c00
commit 2baf509f25
2 changed files with 7 additions and 2 deletions

View File

@ -53,8 +53,10 @@ function add_account_authtoken() {
exit 0
fi
token="$(sed 's/Bearer //g' <<< "$@")"
if check_if_user_exists authToken; then
echo "$(session_get_username ${cookies[sh_session]}):$1" >> secret/authTokens.dat
echo "$(session_get_username ${cookies[sh_session]}):$token" >> secret/authTokens.dat
fi
}

View File

@ -10,6 +10,8 @@ while [[ "$data" == '' ]]; do
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":"'"${post_data[lat]}"'","longitude":"'"${post_data[lon]}"'"},"parcel":{"openCode":"'"${post_data[openCode]}"'","shipmentNumber":"'"${post_data[id]}"'"}}')
done
echo $data > tmpdata
if [[ $(echo $data | jq .status) == "403" ]]; then
echo $data | jq "{status: .status, msg: .error}"
else
@ -19,8 +21,9 @@ else
data=$(curl -X POST -H "$(get_auth_string)" "https://api-inmobile-pl.easypack24.net/v1/collect/compartment/open/$uuid")
done
if [[ $(echo $data | jq ".compartment") != "" ]]; then
echo $data
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 ":o $data"
else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "OCW received an invalid response from the API."
fi
echo $data > tmp_data2
fi