ocw/webroot/api/smscode.shs
2020-10-25 02:33:29 +01:00

19 lines
744 B
Bash

#!/bin/bash
if ! session_verify ${cookies[sh_session]}; then
exit 0
fi
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]}")
if [[ $(echo $tokens | jq .status) == "404" ]]; then
jq -n '{status: $ARGS.positional[0], msg: $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], msg: $ARGS.positional[1]}' --args 200 "success"
fi
fi