epic password change

This commit is contained in:
Shihaam Abdul Rahman 2021-05-07 13:39:27 +05:00
parent 89f8ed49c8
commit 08a71321b7
2 changed files with 78 additions and 35 deletions

View File

@ -1,40 +1,86 @@
read -s -p 'Enter Current Password: ' OLD_PASSWORD
echo ""
echo ""
while true; do
read -s -p 'Enter New Password: ' NEW_PASSWORD
echo ""
read -s -p 'Repeat New Password: ' REPEAT_NEWPASSWORD
echo ""
if [ "$NEW_PASSWORD" = "$REPEAT_NEWPASSWORD" ]
then
sleep 0.2
echo ""
break
else
echo "${red}Password do not match${reset}"
echo "Try again"
echo ""
fi
done
while true; do
echo "Select OTP Method:"
echo "1 - Mobile"
echo "2 - Email"
echo ""
read -p "Please input: " OTPCHANNEL
if [ "$OTPCHANNEL" = "1" ] || [ "$OTPCHANNEL" = "mobile" ]
then
OTPCHANNEL=mobile
break
elif [ "$OTPCHANNEL" = "2" ] || [ "$OTPCHANNEL" = "email" ]
then
OTPCHANNEL=email
break
else
echo "${red}Invalid Input${reset}"
echo ""
fi
done
OLDPASSCHECHECK=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL \
--compressed \
| jq -r .success)
if [ "$OLDPASSCHECHECK" != "true" ]
then
source changepassword.sh
else
:
fi
read -s -p 'Enter Current Password: ' OLD_PASSWORD
echo ""
read -s -p 'Enter New Password: ' NEW_PASSWORD
echo ""
read -s -p 'Repeat New Password: ' REPEAT_NEWPASSWORD
if [ "$NEW_PASSWORD" = "$REPEAT_NEWPASSWORD" ]
then
echo "Select OTP Method:"
echo "1 - Mobile"
echo "2 - Email"
echo ""
echo "Please input: "
read -r OTPCHANNEL
if [ "$OTPCHANNEL" = "1" ]
then
OTPCHANNEL=mobile
elif [ "$OTPCHANNEL" = "2" ]
then
OTPCHANNEL=email
else
echo "${red}Invalid Input${reset}"
fi
if [ "$OTPCHANNEL" = "mobile" ]
then
ECHOOTPCHANNEL=$PHONE
elif [ "$OTPCHANNEL" = "email" ]
then
ECHOOTPCHANNEL=$EMAIL
fi
curl -s -b $COOKIE $BML_URL/user/changepassword' \
echo ""
echo "${lightgreen}OTP sent to ${yellow}${ECHOOTPCHANNEL}${reset}"
read -p 'Enter OTP: ' OTP
echo ""
PASSCHANGED=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL \
--compressed
curl -s -b $COOKIE $BML_URL/user/changepassword' \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
--data-raw channel=$OTPCHANNEL
--data-raw otp=$OTP \
--compressed
--compressed \
| jq -r .success)
if [ "$PASSCHANGED" != "true" ]
then
echo "${red}Failed to change password${reset}"
else
echo "${lightgreen}Password changed succesfully ${reset}"
source settings-menu.sh
fi

View File

@ -39,9 +39,6 @@ elif [ "$MENU" = "5" ]
source services.sh
elif [ "$MENU" = "6" ]
then
echo "WIP"
# sleep 2
# source mainmenu.sh
source settings-menu.sh
elif [ "$MENU" = "clear" ]
then