diff options
-rwxr-xr-x | tessen | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -94,25 +94,31 @@ get_pass_data() { fi } -# get the key that the user will choose to autotype or copy +# SECOND MENU: show a list of possible keys to choose from for auto typing or +# copying +# THIRD MENU: optional, this will show up if TESSEN_ACTION is blank get_key() { local -a key_arr local ch flag=false - if [[ "$1" == "pass_key_list" ]]; then - key_arr=("autotype username and password" "username" "password" "${!tsn_passdata[@]}") - shift - elif [[ "$1" == "opt_key_list" ]]; then - key_arr=("autotype" "copy") - shift - else - exit 1 + # the second menu + if [[ "$1" == "key_list" ]]; then + if [[ "$tsn_otp" == "true" ]]; then + key_arr=("$tsn_autokey" "$tsn_userkey" "password" "otp" "${!tsn_passdata[@]}") + else + key_arr=("$tsn_autokey" "$tsn_userkey" "password" "${!tsn_passdata[@]}") + fi + # the (optional) third menu, depends on $tsn_action + elif [[ "$1" == "option" ]]; then + key_arr=("$tsn_autokey" "copy") + elif [[ "$1" == "$tsn_urlkey" ]]; then + key_arr=("open" "copy") fi - # a dynamically scoped variable to hold the key selection for key_menu - chosen_key="$(printf '%s\n' "${key_arr[@]}" | "$tsn_backend" "$tsn_backend_opts")" + # a dynamically scoped variable to hold the selected key for key_menu + chosen_key="$(printf "%s\n" "${key_arr[@]}" | "$tsn_backend" "$tsn_backend_opts")" - # validate the chosen key name + # validate the chosen key, if it doesn't exist, exit for ch in "${key_arr[@]}"; do if [[ "$chosen_key" == "$ch" ]]; then flag=true |