34 lines
1.2 KiB
Bash
34 lines
1.2 KiB
Bash
#!/bin/bash
|
|
source "${cfg[namespace]}/code/common.sh"
|
|
|
|
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' && "${post_data[mail]}" != '' ]]; then
|
|
mail="$(echo "${post_data[mail]}" | sed -s 's/%40/@/')"
|
|
if [[ "${cfg[hcaptcha]}" == true && $(curl -d "response=${post_data[hcaptcha]}&secret=${cfg[hcaptcha_secret]}" -X POST https://hcaptcha.com/siteverify | jq '.success') != "true" ]]; then
|
|
status=1
|
|
reason="hCaptcha: invalid token"
|
|
elif ! check_mail "$mail"; then
|
|
status=1
|
|
reason="This mail address is already in use!"
|
|
else
|
|
register "${post_data[login]}" "${post_data[password]}"
|
|
status=$?
|
|
verification="$RANDOM"
|
|
|
|
echo "${post_data[login]}:$mail:$verification:no" >> secret/mail.dat
|
|
fi
|
|
|
|
if [[ $status == 0 ]]; then
|
|
sender_name="${cfg[who]}" mailsend "$mail" "OCW mail verification" "Hi ${post_data[login]},
|
|
|
|
Your code: $verification
|
|
|
|
Have a wonderful day!
|
|
~ ${cfg[who]}" &
|
|
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
|
|
else
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "Make sure to fill out the form properly."
|
|
fi
|