29 lines
1.1 KiB
Bash
29 lines
1.1 KiB
Bash
#!/bin/bash
|
|
[[ "${post_data[login]}" == '' ]] && jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 0 "BAD REQUEST" && return
|
|
source "${cfg[namespace]}/code/common.sh"
|
|
|
|
hash="$(account_gen_reset_code "${post_data[login]}")"
|
|
result=$?
|
|
|
|
if [[ $result == 1 ]]; then
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 1 "This account doesn't exist or wasn't verified."
|
|
elif [[ $result == 2 ]]; then
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 2 "Ratelimited."
|
|
elif [[ $result == 0 ]]; then
|
|
sender_name="${cfg[who]}" mailsend "$(get_account_mail ${post_data[login]})" "OCW password reset" \
|
|
"Hi ${post_data[login]},
|
|
|
|
Someone (probably you) has requested a password reset on your OCW account.
|
|
To reset your password, paste below text into the password reset form:
|
|
|
|
$hash
|
|
|
|
NEVER give this code to anybody - this would grant full control over your account.
|
|
If you didn't request a password reset, you can safely ignore this message.
|
|
|
|
Have a wonderful day!
|
|
~ ${cfg[who]}" &
|
|
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args 200 "Reset e-mail sent!"
|
|
fi
|