From 38f6447681d20cef313ed270cc67edc99a5ab3e2 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Fri, 17 May 2024 22:44:46 +0300 Subject: [PATCH] fix: Show the totp code in `get` command Fixes: https://git.4rs.nl/awiteb/lprs/issues/46 --- src/cli/get_command.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cli/get_command.rs b/src/cli/get_command.rs index 6c6a39e..7b54c69 100644 --- a/src/cli/get_command.rs +++ b/src/cli/get_command.rs @@ -24,6 +24,7 @@ use crate::{ LprsCommand, LprsError, LprsResult, + RESERVED_FIELD_PREFIX, }; #[derive(Debug, Clone, Eq, PartialEq)] @@ -138,6 +139,12 @@ impl LprsCommand for Get { ))); } } else { + if let Some(ref totp_secret) = vault.totp_secret { + let code = cipher::totp_now(totp_secret, &vault.totp_hash)?.0; + vault + .custom_fields + .insert(format!("{RESERVED_FIELD_PREFIX}TOTP Code"), code); + } println!("{vault}"); } Ok(())