2020-09-19 19:53:02 +02:00
|
|
|
#!/bin/bash
|
2020-10-29 22:23:06 +01:00
|
|
|
source "${cfg[namespace]}/code/common.sh"
|
2020-09-19 19:53:02 +02:00
|
|
|
|
2020-10-29 22:23:06 +01:00
|
|
|
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' && "${post_data[mail]}" != '' ]]; then
|
2020-10-29 23:28:09 +01:00
|
|
|
mail="$(echo "${post_data[mail]}" | sed -s 's/%40/@/')"
|
|
|
|
if ! check_mail "$mail"; then
|
2020-10-29 22:23:06 +01:00
|
|
|
status=1
|
|
|
|
reason="This mail address is already in use!"
|
|
|
|
else
|
|
|
|
register "${post_data[login]}" "${post_data[password]}"
|
|
|
|
status=$?
|
|
|
|
verification="$RANDOM"
|
2020-10-29 23:28:09 +01:00
|
|
|
|
|
|
|
echo "${post_data[login]}:$mail:$verification:no" >> secret/mail.dat
|
2020-10-29 22:23:06 +01:00
|
|
|
fi
|
|
|
|
|
2020-09-19 19:53:02 +02:00
|
|
|
if [[ $status == 0 ]]; then
|
2020-10-29 23:28:09 +01:00
|
|
|
sender_name="${cfg[who]}" mailsend "$mail" "OCW mail verification" "Hi ${post_data[login]},
|
2020-10-29 22:23:06 +01:00
|
|
|
|
|
|
|
Your code: $verification
|
|
|
|
|
|
|
|
Have a wonderful day!
|
|
|
|
~ ${cfg[who]}" &
|
2020-10-25 02:30:47 +01:00
|
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 "success"
|
2020-09-19 19:53:02 +02:00
|
|
|
elif [[ $status == 1 && $reason != '' ]]; then
|
2020-10-25 02:30:47 +01:00
|
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "$reason"
|
2020-09-19 19:53:02 +02:00
|
|
|
fi
|
2020-10-25 02:30:47 +01:00
|
|
|
fi
|