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
|
|
|
|
if ! check_mail "${post_data[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]}:${post_data[mail]}:$verification:no" >> secret/mail.dat
|
|
|
|
fi
|
|
|
|
|
2020-09-19 19:53:02 +02:00
|
|
|
if [[ $status == 0 ]]; then
|
2020-10-29 22:23:06 +01:00
|
|
|
sender_name="${cfg[who]}" mailsend "${post_data[mail]}" "OCW mail verification" "Hi ${post_data[login]},
|
|
|
|
|
|
|
|
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
|