Can delete a pending device

This commit is contained in:
2024-07-03 21:10:15 +02:00
parent 716af6219a
commit 2502ed6bcf
6 changed files with 120 additions and 9 deletions

View File

@ -95,4 +95,27 @@ impl DevicesList {
pub fn full_list(&self) -> Vec<Device> {
self.0.clone().into_values().collect()
}
/// Delete a device
pub fn delete(&mut self, id: &DeviceId) -> anyhow::Result<()> {
let crt_path = AppConfig::get().device_cert_path(id);
if crt_path.is_file() {
// TODO : implement
unimplemented!("Certificate revocation not implemented yet!");
}
let csr_path = AppConfig::get().device_csr_path(id);
if csr_path.is_file() {
std::fs::remove_file(&csr_path)?;
}
let conf_path = AppConfig::get().device_config_path(id);
if conf_path.is_file() {
std::fs::remove_file(&conf_path)?;
}
self.0.remove(id);
Ok(())
}
}