diff --git a/webroot/api/mailcode.shs b/webroot/api/mailcode.shs index 4d0eaad..53c37e6 100644 --- a/webroot/api/mailcode.shs +++ b/webroot/api/mailcode.shs @@ -4,15 +4,16 @@ if ! session_verify "${cookies[sh_session]}"; then return fi +source "${cfg[namespace]}/code/common.sh" if [[ "${post_data[code]}" != '' && "${post_data[phone]}" != '' ]]; then - username="$(session_get_username ${cookies[sh_session]})" + 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 + elif [[ $status == 1 ]]; then jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "$reason" fi fi