tfa: remove tfa user when a user is deleted

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-12-11 14:34:47 +01:00
parent 4bda51688b
commit f22dfb5ece
2 changed files with 26 additions and 0 deletions

View File

@ -247,6 +247,18 @@ impl TfaConfig {
None => bail!("no 2nd factor available for user '{}'", userid),
}
}
/// Remove non-existent users.
pub fn cleanup_users(&mut self, config: &proxmox::api::section_config::SectionConfigData) {
use crate::config::user::User;
self.users
.retain(|user, _| config.lookup::<User>("user", user.as_str()).is_ok());
}
/// Remove a user. Returns `true` if the user actually existed.
pub fn remove_user(&mut self, user: &Userid) -> bool {
self.users.remove(user).is_some()
}
}
#[api]