2023-01-17 01:46:39 +11:00
#Account hoardan
whoami( ) { echo $INSTANCE $TOKE ; }
2023-01-17 03:30:28 +11:00
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 \"} " ) "
2023-06-19 00:07:45 +10:00
if [ ! $( jq .error <<< " $result " ) = = "captcha_incorrect" ] ; then
jq <<< " $result " ; exit;
2023-01-17 03:30:28 +11:00
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 \"} "
}