tfa: add 'created' timestamp to entries

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-01-18 13:50:00 +01:00
committed by Thomas Lamprecht
parent bad6e32075
commit ad5cee1d22
2 changed files with 32 additions and 12 deletions

View File

@ -82,12 +82,12 @@ fn to_data(data: TfaUserData) -> Vec<TypedTfaInfo> {
data.totp.len()
+ data.u2f.len()
+ data.webauthn.len()
+ if data.has_recovery() { 1 } else { 0 },
+ if data.recovery().is_some() { 1 } else { 0 },
);
if data.has_recovery() {
if let Some(recovery) = data.recovery() {
out.push(TypedTfaInfo {
ty: TfaType::Recovery,
info: TfaInfo::recovery(),
info: TfaInfo::recovery(recovery.created),
})
}
for entry in data.totp {
@ -184,10 +184,12 @@ fn get_tfa_entry(userid: Userid, id: String) -> Result<TypedTfaInfo, Error> {
entry.map(|(ty, index, _)| (ty, index))
} {
Some((TfaType::Recovery, _)) => {
return Ok(TypedTfaInfo {
ty: TfaType::Recovery,
info: TfaInfo::recovery(),
})
if let Some(recovery) = user_data.recovery() {
return Ok(TypedTfaInfo {
ty: TfaType::Recovery,
info: TfaInfo::recovery(recovery.created),
});
}
}
Some((TfaType::Totp, index)) => {
return Ok(TypedTfaInfo {