Now detects incorrect username/password

This commit is contained in:
Henric Andersson 2015-07-31 12:53:15 -07:00
commit 0e7f98756f

View file

@ -136,6 +136,7 @@ keypair() {
function cleanup { function cleanup {
rm /tmp/kaka 2>/dev/null >/dev/null rm /tmp/kaka 2>/dev/null >/dev/null
rm /tmp/postdata 2>/dev/null >/dev/null rm /tmp/postdata 2>/dev/null >/dev/null
rm /tmp/raw 2>/dev/null >/dev/null
} }
trap cleanup EXIT trap cleanup EXIT
@ -171,15 +172,17 @@ if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ] && [ "${PUBLIC}" == "no" ]; then
echo -ne >>/tmp/postdata "&$(keypair "commit" "Sign in" )" echo -ne >>/tmp/postdata "&$(keypair "commit" "Sign in" )"
# Authenticate # Authenticate
wget --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies "${URL_LOGIN}" --post-file=/tmp/postdata -O /dev/null 2>/dev/null wget --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies "${URL_LOGIN}" --post-file=/tmp/postdata -O /tmp/raw 2>/dev/null
RET=$? if [ $? -ne 0 ]; then
echo "Error: Unable to authenticate"
exit 1
fi
# Delete authentication data ... Bad idea to let that stick around # Delete authentication data ... Bad idea to let that stick around
rm /tmp/postdata rm /tmp/postdata
# Provide some details to the end user # Provide some details to the end user
if [ ${RET} -ne 0 ]; then if [ "$(cat /tmp/raw | grep 'Sign In</title')" != "" ]; then
echo "Error: Unable to authenticate" echo "Error: Username and/or password incorrect"
exit 1 exit 1
fi fi
echo "OK" echo "OK"