Added Account locked, more detailed errors
This commit is contained in:
parent
d9f84b6808
commit
fd04529620
3
bml.sh
3
bml.sh
@ -5,6 +5,7 @@
|
||||
#Setting intial variables
|
||||
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
||||
COOKIE=/tmp/bmlcookie
|
||||
CREDENTIALS=.env
|
||||
|
||||
#Setting terminal output colors
|
||||
red=`tput setaf 1`
|
||||
@ -12,4 +13,4 @@ green=`tput setaf 2`
|
||||
reset=`tput sgr0`
|
||||
|
||||
|
||||
source password.sh
|
||||
source readpass.sh
|
||||
|
27
login.sh
27
login.sh
@ -1,27 +1,24 @@
|
||||
#!/bin/bash
|
||||
#login and generate cookie
|
||||
|
||||
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
|
||||
--data-raw username=$BML_USERNAME \
|
||||
--data-raw password=${BML_PASSWORD} \
|
||||
--compressed \
|
||||
| jq -r .success)
|
||||
| jq -r .code)
|
||||
#check if login was success
|
||||
if [ "$LOGIN" = "true" ]
|
||||
if [ "$LOGIN" = "0" ]
|
||||
then
|
||||
#Requesting for User profile after login and regex to grap the Full name
|
||||
NAME=$(curl -s -b $COOKIE $BML_URL/profile \
|
||||
| awk -F 'fullname":"' '{print $2}' \
|
||||
| cut -f1 -d '"')
|
||||
#display a Welcome message with fullname
|
||||
echo ""
|
||||
echo ${green}Welcome ${reset}$NAME
|
||||
# curl -s -b $COOKIE $BML_URL/userinfo
|
||||
echo ""
|
||||
source mainmenu.sh
|
||||
source savepass.sh
|
||||
elif [ "$LOGIN" = "20" ]
|
||||
then
|
||||
echo "${red}Account Locked!${reset}"
|
||||
exit
|
||||
elif [ "$LOGIN" = "2" ]
|
||||
then
|
||||
source readpass.sh
|
||||
else
|
||||
#Display error if login was not succuessfull and delete cookie
|
||||
echo "${red}An error occured, Please check Username and Password" 1>&2
|
||||
rm $COOKIE 2> /dev/null
|
||||
echo "${red}Unknown Error${reset}" 1>&2
|
||||
exit
|
||||
fi
|
||||
|
||||
|
29
readpass.sh
Normal file
29
readpass.sh
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
if [ -f $CREDENTIALS ]
|
||||
then
|
||||
source $CREDENTIALS
|
||||
elif [ "$LOGIN" = "2" ]
|
||||
then
|
||||
if [ -f $CREDENTIALS ]
|
||||
then
|
||||
echo "${red}Saved Credentials has been changed${reset}"
|
||||
rm $CREDENTIALS
|
||||
else
|
||||
echo "${red}Username or Password incorrect${reset}"
|
||||
fi
|
||||
read -p 'Username: ' BML_USERNAME
|
||||
read -s -p 'Password: ' BML_PASSWORD
|
||||
echo ""
|
||||
|
||||
elif [ ! -f $CREDENTIALS ]
|
||||
then
|
||||
echo "${red}Password file not found in $CREDENTIALS${reset}"
|
||||
read -p 'Username: ' BML_USERNAME
|
||||
read -s -p 'Password: ' BML_PASSWORD
|
||||
echo ""
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
|
||||
source login.sh
|
27
savepass.sh
Normal file
27
savepass.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#echo "Do ${red}NOT${reset} save password if password contain '|' '^' '$' '&' ';' ':' '(' ')' "
|
||||
|
||||
if [ ! -f $CREDENTIALS ]
|
||||
then
|
||||
if [ "$LOGIN" = "0" ]
|
||||
then
|
||||
read -p 'Do you want to save login? [y/N] ' SAVE_LOGIN
|
||||
if [ "$SAVE_LOGIN" = "Y" ]
|
||||
then
|
||||
echo BML_USERNAME=''${BML_USERNAME}'' > $CREDENTIALS
|
||||
echo BML_PASSWORD=''${BML_PASSWORD}'' >> $CREDENTIALS
|
||||
|
||||
elif [ "$SAVE_LOGIN" = "y" ]
|
||||
then
|
||||
echo BML_USERNAME=''${BML_USERNAME}'' > $CREDENTIALS
|
||||
echo BML_PASSWORD=''${BML_PASSWORD}'' >> $CREDENTIALS
|
||||
else
|
||||
:
|
||||
fi
|
||||
else
|
||||
source readpass.sh
|
||||
fi
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
source welcome.sh
|
11
welcome.sh
Normal file
11
welcome.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#Requesting for User profile after login and regex to grap the Full name
|
||||
NAME=$(curl -s -b $COOKIE $BML_URL/profile \
|
||||
| awk -F 'fullname":"' '{print $2}' \
|
||||
| cut -f1 -d '"')
|
||||
|
||||
#display a Welcome message with fullname
|
||||
echo ""
|
||||
echo ${green}Welcome ${reset}$NAME
|
||||
#curl -s -b $COOKIE $BML_URL/userinfo
|
||||
echo ""
|
||||
source mainmenu.sh
|
Loading…
x
Reference in New Issue
Block a user