I think registration works now
This commit is contained in:
parent
c6a7ceb005
commit
21a9042fcf
|
@ -6,8 +6,9 @@ source ./pretty.sh
|
|||
source ./creds.sh
|
||||
source ./utils.sh
|
||||
|
||||
while getopts "a:hv" o;do case "${o}" in
|
||||
while getopts "a:i:hv" o;do case "${o}" in
|
||||
a) INSTANCE=${insts[$OPTARG]}; TOKE=${tokes[$OPTARG]};;
|
||||
i) INSTANCE=$OPTARG;;
|
||||
h) echo $actions; exit;;
|
||||
v) echo 0.1.0; exit;;
|
||||
esac done
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#Account hoardan
|
||||
whoami(){ echo $INSTANCE $TOKE; }
|
||||
login(){ post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}"; }
|
||||
login()
|
||||
{
|
||||
post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}"
|
||||
}
|
||||
register()
|
||||
{
|
||||
get "site" ".site_view.site | .open_registration,.require_email_verification,.require_application,.application_question" | jq -r . | read reg em app appq
|
||||
if [ $reg == false ]; then
|
||||
echo "Sorry, this instance does not accept registrations; try to contact them to ask for an account."; exit
|
||||
fi
|
||||
if [ $em == true ]; then em="(required)"; else em=""; fi
|
||||
namedget reg_username "Desired username (required)"
|
||||
namedget reg_pw "Password (required)"
|
||||
namedget reg_pw2 "Verify password"
|
||||
if [ ! reg_pw == reg_pw2 ]; then echo "passwords don't match (continuing anyway, expect failure later though)"; fi
|
||||
namedget reg_email "Email address $em"
|
||||
if [ $app == true ]; then namedget reg_appa "Application question: $appq"; fi
|
||||
result="$(post "user/register" "{\"username\":\"$reg_username\",\"password\":\"$reg_pw\",\"password_verify\":\"$reg_pw2\",\"email\":\"$reg_email\",\"answer\":\"$reg_appa\"}")"
|
||||
if [ ! $(jq .error <<< "result") == "captcha_incorrect" ]; then
|
||||
jq <<< "result"; exit;
|
||||
fi
|
||||
a="$(get "user/get_captcha" ".ok")"
|
||||
reg_uuid=$(jq -r '.uuid' <<< "$a")
|
||||
jq -r '.wav' <<< "$a" | base64 -d > "captcha.wav"
|
||||
jq -r '.png' <<< "$a" | base64 -d > "captcha.png"
|
||||
namedget reg_captcha "Please open captcha.wav and captcha.png and input the text - in that order, no spaces"
|
||||
post "user/register" "{\"username\":\"$reg_username\",\"password\":\"$reg_pw\",\"password_verify\":\"$reg_pw2\",\"email\":\"$reg_email\",\"answer\":\"$reg_appa\",\"captcha_uuid\":\"$reg_uuid\",\"captcha_answer\":\"$reg_captcha\"}"
|
||||
}
|
23
utils.sh
23
utils.sh
|
@ -1,2 +1,23 @@
|
|||
#Utils
|
||||
getbody(){ a=$(cat); while read n; do b="$b\n$n"; done <<< "$a"; c=${b//\"/\\\"}; body="${c:2}"; }
|
||||
|
||||
getbody()
|
||||
{
|
||||
echo "Write your comment, press ctrl+d on a blank line to submit"
|
||||
a=$(cat)
|
||||
while read n; do
|
||||
b="$b\n$n"
|
||||
done <<< "$a"
|
||||
c=${b//\"/\\\"}
|
||||
body="${c:2}"
|
||||
}
|
||||
|
||||
namedget()
|
||||
{
|
||||
echo $2:
|
||||
if [ $3 ]; then
|
||||
echo "(Press ctrl+d on a blank line to submit)"
|
||||
read $1 <<< $(cat)
|
||||
else
|
||||
read $1
|
||||
fi
|
||||
}
|
Loading…
Reference in New Issue
Block a user