ocw/webroot/api/mailcode.shs

19 lines
875 B
Bash

#!/bin/bash
if ! session_verify "${cookies[sh_session]}"; then
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "You're not logged in!"
return
fi
if [[ "${post_data[code]}" != '' && "${post_data[phone]}" != '' ]]; then
username="$(session_get_username ${cookies[sh_session]})"
mail="$(get_account_mail $username)"
if [[ "$(cat secret/mail.dat | grep "$username:" | grep ":${post_data[code]}:")" != '' ]]; then
sed -i "s/$username:$mail:${post_data[code]}:no/$username:$mail:${post_data[code]}:yes/" secret/mail.dat
curl -s "https://api-inmobile-pl.easypack24.net/v1/sendSMSCode/${post_data[phone]}" > /dev/null
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 "success"
elif [[ $status == 1 && $reason != '' ]]; then
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "$reason"
fi
fi