fix: Show the totp code in get command

Fixes: #46
This commit is contained in:
Awiteb 2024-05-17 22:44:46 +03:00
parent 02bf53b2a1
commit 38f6447681
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -24,6 +24,7 @@ use crate::{
LprsCommand, LprsCommand,
LprsError, LprsError,
LprsResult, LprsResult,
RESERVED_FIELD_PREFIX,
}; };
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
@ -138,6 +139,12 @@ impl LprsCommand for Get {
))); )));
} }
} else { } 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}"); println!("{vault}");
} }
Ok(()) Ok(())