Can remove clients

This commit is contained in:
2025-01-27 22:07:18 +01:00
parent 2c14281ae3
commit 9a46cbd819
3 changed files with 43 additions and 1 deletions

View File

@ -50,6 +50,9 @@ pub struct FormRequest {
/// Restrict new client to a given network
ip_network: Option<String>,
/// Delete a specified client id
delete_client_id: Option<uuid::Uuid>,
}
/// Main route
@ -114,6 +117,14 @@ pub async fn home(session: Session, form_req: Option<web::Form<FormRequest>>) ->
config.save().await?;
}
}
// Delete a client
if let Some(delete_client_id) = form_req.0.delete_client_id {
config.clients.retain(|c| c.id != delete_client_id);
config.save().await?;
success_message = Some("The client was successfully deleted!".to_string());
// TODO : close connections with given id
}
}
// Render page