diff --git a/webroot/api/register.shs b/webroot/api/register.shs new file mode 100644 index 0000000..e37e827 --- /dev/null +++ b/webroot/api/register.shs @@ -0,0 +1,11 @@ +#!/bin/bash + +if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then + register ${post_data[login]} ${post_data[password]} + status=$? + if [[ $status == 0 ]]; then + jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args 200 "success" + elif [[ $status == 1 && $reason != '' ]]; then + jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "$reason" + fi +fi \ No newline at end of file diff --git a/webroot/api/smscode.shs b/webroot/api/smscode.shs new file mode 100644 index 0000000..7acff41 --- /dev/null +++ b/webroot/api/smscode.shs @@ -0,0 +1,16 @@ +#!/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]}") + + if [[ $(echo $tokens | jq .status) == "404" ]]; then + jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "wrongData" + else + add_account_refreshtoken $(echo $tokens | jq -r .refreshToken) + add_account_authtoken $(echo $tokens | jq -r .authToken) + jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args 200 "success" + fi +fi diff --git a/webroot/register.shs b/webroot/register.shs deleted file mode 100644 index 45de7aa..0000000 --- a/webroot/register.shs +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 deleted file mode 100644 index c4ff167..0000000 --- a/webroot/smscode.shs +++ /dev/null @@ -1,21 +0,0 @@ -#!/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