* fixes authToken update problem

This commit is contained in:
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 exit 0
fi fi
token="$(sed 's/Bearer //g' <<< "$@")"
if check_if_user_exists authToken; then 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 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]}"'"}}') 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 done
echo $data > tmpdata
if [[ $(echo $data | jq .status) == "403" ]]; then if [[ $(echo $data | jq .status) == "403" ]]; then
echo $data | jq "{status: .status, msg: .error}" echo $data | jq "{status: .status, msg: .error}"
else 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") data=$(curl -X POST -H "$(get_auth_string)" "https://api-inmobile-pl.easypack24.net/v1/collect/compartment/open/$uuid")
done done
if [[ $(echo $data | jq ".compartment") != "" ]]; then if [[ $(echo $data | jq ".compartment") != "" ]]; then
echo $data jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 ":o $data"
else else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "OCW received an invalid response from the API." jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "OCW received an invalid response from the API."
fi fi
echo $data > tmp_data2
fi fi