feat: mantain committee group as well

This commit is contained in:
silver 2023-06-18 18:37:44 +01:00
parent 9cba5ce94a
commit a3e95c5e10

View file

@ -9,6 +9,7 @@ async fn main() -> tide::Result<()> {
//update_users(&config).await;
update_admin(&config).await?;
update_committee(&config).await?;
Ok(())
}
@ -34,6 +35,20 @@ async fn update_admin(config: &Config) -> tide::Result<()> {
Ok(())
}
async fn update_committee(config: &Config) -> tide::Result<()> {
dotenv().ok();
// read from teh env
if let Ok(x) = env::var("USERS_COMMITTEE") {
let users = x.split(',').collect::<Vec<&str>>();
update_group(config, "skynet-committee", &users, true).await?;
// admins automatically get added as users
update_group(config, "skynet-users", &users, false).await?;
}
Ok(())
}
async fn update_group(config: &Config, group: &str, users: &[&str], replace: bool) -> tide::Result<()> {
let mut ldap = LdapConn::new(&config.ldap_host)?;