promt to login if logged in from another app while using bml-cli

This commit is contained in:
Shihaam Abdul Rahman 2021-05-19 23:32:03 +05:00
parent 731a5684df
commit 28afb928dd

View File

@ -152,7 +152,7 @@ urandom(){
BML_USERNAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) BML_USERNAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
BML_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) BML_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
REPEAT_PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) REPEAT_PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) NEW_PIN=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
} }
savepass(){ savepass(){
if [ "$BML_USERNAME" = "" ] && [ "$BML_PASSWORD" = "" ] if [ "$BML_USERNAME" = "" ] && [ "$BML_PASSWORD" = "" ]
@ -184,7 +184,7 @@ savepass(){
else else
: :
fi fi
urandom && select_profile select_profile # urandom && select_profile
} }
################################################################################################ ################################################################################################
@ -283,11 +283,18 @@ accounts(){
################################################################################################ ################################################################################################
list_contacts(){ list_contacts(){
echo $API_CONATCTS | jq -r '["ID","Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.id, .account, .currency, .name, .alias]) | @tsv' echo $API_CONATACTS | jq -r '["ID","Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.id, .account, .currency, .name, .alias]) | @tsv'
} }
################################################################################################ ################################################################################################
api_contacts(){ api_contacts(){
API_CONATCTS=$(curl -s -b $COOKIE $BML_URL/contacts) API_CONATACTS=$(curl -s -b $COOKIE $BML_URL/contacts)
SUCCESS=$(echo $API_CONATACTS | jq -r .success)
if [ "$SUCCESS" != "true" ]
then
echo "Login Required"
init_login
api_contacts
fi
} }
################################################################################################ ################################################################################################
@ -539,15 +546,18 @@ then
initialize initialize
fi fi
banner && check_connection #& animate "Checking Internet Connection" init_login(){
banner && os_detect #& animate "Detecting Operating System" if [ "$BML_USERNAME" != "" ] && [ "$BML_PASSWORD" != "" ]
then
readpin
else
enter_credentials
fi
}
banner && check_connection & animate "Checking Internet Connection"
banner && os_detect & animate "Detecting Operating System"
source $CONFIG source $CONFIG
source $CREDENTIALS source $CREDENTIALS
if [ "$BML_USERNAME" != "" ] && [ "$BML_PASSWORD" != "" ] banner && init_login
then
readpin
else
enter_credentials
fi
userinfo userinfo
banner && display_welcome && display_user_info && main_menu banner && display_welcome && display_user_info && main_menu