v-delete-user-2fa 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # info: delete 2fa of existing user
  3. # options: USER
  4. # labels: hestia panel
  5. #
  6. # example: v-delete-user-2fa admin
  7. #
  8. # The function deletes 2fa token of a user.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. # Includes
  15. source $HESTIA/func/main.sh
  16. source $HESTIA/conf/hestia.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '1' "$#" 'USER'
  21. is_format_valid 'user' 'system'
  22. is_object_valid 'user' 'USER' "$user"
  23. # Perform verification if read-only mode is enabled
  24. check_hestia_demo_mode
  25. #----------------------------------------------------------#
  26. # Action #
  27. #----------------------------------------------------------#
  28. # Reading user values
  29. source $USER_DATA/user.conf
  30. # Check if 2FA is enabled
  31. if [ -z "$TWOFA" ]; then
  32. echo "Error: two-factor authentication is not enabled"
  33. exit $E_NOTEXIST
  34. fi
  35. # Remove 2FA from user config
  36. update_user_value "$user" '$TWOFA' ""
  37. update_user_value "$user" '$QRCODE' ""
  38. #----------------------------------------------------------#
  39. # Hestia #
  40. #----------------------------------------------------------#
  41. log_history "[WARNING] two-factor authentication disabled for $user"
  42. log_event "$OK" "$ARGUMENTS"
  43. exit