fixed smscode endpoint, fixed verification
This commit is contained in:
parent
b45074a315
commit
aba30eaaa4
|
@ -10,12 +10,33 @@ function get_auth_string() {
|
||||||
echo "Authorization: Bearer $(cat secret/authToken)"
|
echo "Authorization: Bearer $(cat secret/authToken)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check_if_user_exists(file)
|
||||||
|
function check_if_user_exists() {
|
||||||
|
if ! session_verify ${cookies[sh_session]}; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $1 == "refreshToken" ]]; then
|
||||||
|
if [[ $(cat secret/refreshTokens.dat | grep "${cookies[sh_session]}:") != "" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
elif [[ $1 == "authToken" ]]; then
|
||||||
|
if [[ $(cat secret/authTokens.dat | grep "${cookies[sh_session]}:") != "" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# add_account_refreshtoken(refreshtoken)
|
# add_account_refreshtoken(refreshtoken)
|
||||||
function add_account_refreshtoken() {
|
function add_account_refreshtoken() {
|
||||||
if ! session_verify ${cookies[sh_session]}; then
|
if ! session_verify ${cookies[sh_session]}; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo $(session_get_username ${cookies[sh_session]}):$1 >> secret/refreshTokens.dat
|
|
||||||
|
if check_if_user_exists refreshToken; then
|
||||||
|
echo ${cookies[sh_session]}:$1 >> secret/refreshTokens.dat
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,5 +45,8 @@ function add_account_authtoken() {
|
||||||
if ! session_verify ${cookies[sh_session]}; then
|
if ! session_verify ${cookies[sh_session]}; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo $(session_get_username ${cookies[sh_session]}):$1 >> secret/authTokens.dat
|
|
||||||
|
if check_if_user_exists authToken; then
|
||||||
|
echo ${cookies[sh_session]}:$1 >> secret/authTokens.dat
|
||||||
|
fi
|
||||||
}
|
}
|
0
secret/authTokens.dat
Normal file
0
secret/authTokens.dat
Normal file
0
secret/refreshTokens.dat
Normal file
0
secret/refreshTokens.dat
Normal file
|
@ -1,10 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then
|
if [[ ${post_data[login]} != '' && ${post_data[password]} != '' && ${post_data[phone]} != '' ]]; then
|
||||||
register ${post_data[login]} ${post_data[password]}
|
register ${post_data[login]} ${post_data[password]}
|
||||||
status=$?
|
status=$?
|
||||||
if [[ $status == 0 ]]; then
|
if [[ $status == 0 ]]; then
|
||||||
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args 200 "success"
|
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args 200 "success"
|
||||||
|
curl -s "https://api-inmobile-pl.easypack24.net/v1/sendSMSCode/${post_data[phone]}" > /dev/null
|
||||||
elif [[ $status == 1 && $reason != '' ]]; then
|
elif [[ $status == 1 && $reason != '' ]]; then
|
||||||
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "$reason"
|
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "$reason"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,8 +3,10 @@ if ! session_verify ${cookies[sh_session]}; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${get_data[phone]} != "" && ${post_data[code]} != "" ]]; then
|
source code/common.sh
|
||||||
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 [[ ${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
|
if [[ $(echo $tokens | jq .status) == "404" ]]; then
|
||||||
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "wrongData"
|
jq -n '{status: $ARGS.positional[0], error: $ARGS.positional[1]}' --args -1 "wrongData"
|
||||||
|
|
Loading…
Reference in a new issue