From 4c3e80bdf45ab1a4ac6a7b620787da4d87cc9049 Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Wed, 16 Feb 2022 22:12:31 +0530 Subject: feat: add support for OTP when using gopass refactor: offload the autotype and copy operation to key_action --- tessen | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'tessen') diff --git a/tessen b/tessen index 6877f77..abe75b0 100755 --- a/tessen +++ b/tessen @@ -373,25 +373,27 @@ key_action() { } # THIRD MENU: optional, this function is used if an 'otpauth://' URI is found +# note that OTP support in gopass is deprecated and if they end up removing +# support for it, we'll have to make changes here as well key_otp() { local tmp_otp - if ! pass otp -h > /dev/null 2>&1; then + if [[ "$pass_backend" == "pass" ]] && ! pass otp -h > /dev/null 2>&1; then _die "pass-otp is not installed" fi - tmp_otp="$(pass otp "$tsn_passfile")" + if [[ "$pass_backend" == "pass" ]]; then + tmp_otp="$(pass otp "$tsn_passfile")" + elif [[ "$pass_backend" == "gopass" ]]; then + tmp_otp="$(gopass otp -o "$tsn_passfile")" + fi - if [[ "$tmp_otp" =~ ^[[:digit:]]+$ ]]; then - get_key option - if [[ "$chosen_key" == "$tsn_autokey" ]]; then - auto_type "$tmp_otp" - else - wld_copy "$tmp_otp" - fi - else + if ! [[ "$tmp_otp" =~ ^[[:digit:]]+$ ]]; then _die "invalid OTP detected" fi + key_action "$tmp_otp" + + unset -v tmp_otp } # THIRD MENU: optional, this function is used if TESSEN_URLKEY is found. -- cgit v1.2.3