commit ba6a05dad15bf42feefec2c2a02697cb98fe84b7 Author: Dominika Date: Sat Sep 19 17:21:38 2020 +0200 initial commit diff --git a/code/common.sh b/code/common.sh new file mode 100644 index 0000000..215772e --- /dev/null +++ b/code/common.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# common.sh - common functions for OPS app + +# get_auth_string() +function get_auth_string() { + if ! session_verify ${cookies[sh_session]}; then + exit 0 + fi + + echo "Authorization: Bearer $(cat secret/authToken)" +} + +# add_account_refreshtoken(refreshtoken) +function add_account_refreshtoken() { + if ! session_verify ${cookies[sh_session]}; then + exit 0 + fi + echo $(session_get_username ${cookies[sh_session]}):$1 >> secret/refreshTokens.dat +} + + +# add_account_authtoken(authtoken) +function add_account_authtoken() { + if ! session_verify ${cookies[sh_session]}; then + exit 0 + fi + echo $(session_get_username ${cookies[sh_session]}):$1 >> secret/authTokens.dat +} \ No newline at end of file diff --git a/webroot/api/packages.shs b/webroot/api/packages.shs new file mode 100644 index 0000000..be4b4a5 --- /dev/null +++ b/webroot/api/packages.shs @@ -0,0 +1,20 @@ +#!/bin/bash +if ! session_verify ${cookies[sh_session]}; then + exit 0 +fi + +source 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") + +IFS=$'\n' +shipmentNumber=($(echo $data | jq -cr .[].shipmentNumber)) +expiryDate=($(echo $data | jq -cr .[].expiryDate)) +openCode=($(echo $data | jq -cr .[].openCode)) +pickupPointLocation=($(echo $data | jq -cr .[].pickupPoint.location)) +pickupPointName=($(echo $data | jq -cr .[].pickupPoint.name)) +senderName=($(echo $data | jq -cr .[].senderName)) + +for i in ${pickupPointLocation[@]}; do + echo $i; +done \ No newline at end of file diff --git a/webroot/login.shs b/webroot/login.shs new file mode 100644 index 0000000..63e818b --- /dev/null +++ b/webroot/login.shs @@ -0,0 +1,30 @@ +#!/bin/bash + +if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then + login ${post_data[login]} ${post_data[password]} + status=$? + if [[ $status == 0 ]]; then + echo ${get_data[r]} > /dev/stderr + if [[ ${get_data[r]} == '' ]]; then + meta[redirect]='/' + else + meta[redirect]="$(echo ${get_data[r]} | sed -s 's/Log in... +
+ +
+ +
+ +
+(please make sure that you're connecting over SSL)" diff --git a/webroot/logout.shs b/webroot/logout.shs new file mode 100644 index 0000000..538ef39 --- /dev/null +++ b/webroot/logout.shs @@ -0,0 +1,7 @@ +#!/bin/bash + +logout +meta[redirect]='/' +source templates/head.sh + +echo "Logged out successully. Redirecting.." diff --git a/webroot/register.shs b/webroot/register.shs new file mode 100644 index 0000000..45de7aa --- /dev/null +++ b/webroot/register.shs @@ -0,0 +1,28 @@ +#!/bin/bash + +if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then + register ${post_data[login]} ${post_data[password]} + status=$? + if [[ $status == 0 ]]; then + + meta[redirect]='/smscode.shs?phone='${post_data[phone]} + fi +fi + +source templates/head.sh + +if [[ $status == 1 && $reason != '' ]]; then + echo $reason +fi + +echo "

Register

+
+ +
+ +
+ +
+ +
+(please make sure that you're connecting over SSL)" diff --git a/webroot/smscode.shs b/webroot/smscode.shs new file mode 100644 index 0000000..c4ff167 --- /dev/null +++ b/webroot/smscode.shs @@ -0,0 +1,21 @@ +#!/bin/bash +if ! session_verify ${cookies[sh_session]}; then + exit 0 +fi + +if [[ ${get_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/${get_data[phone]}/${post_data[code]}") + + add_account_refreshtoken $(echo $tokens | jq -r .refreshToken) + add_account_authtoken $(echo $tokens | jq -r .authToken) + + echo "success! the token was added to the database!" + +elif [[ ${get_data[phone]} != "" ]]; then + curl -s "https://api-inmobile-pl.easypack24.net/v1/sendSMSCode/${get_data[phone]}" > /dev/null + echo "
+ +
+ +
" +fi diff --git a/workers/updateKeys/control b/workers/updateKeys/control new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/workers/updateKeys/control @@ -0,0 +1 @@ + diff --git a/workers/updateKeys/worker.sh b/workers/updateKeys/worker.sh new file mode 100755 index 0000000..7d98e7e --- /dev/null +++ b/workers/updateKeys/worker.sh @@ -0,0 +1,2 @@ +#!/bin/bash +date \ No newline at end of file