diff --git a/src/bin/update_groups.rs b/src/bin/update_groups.rs index c5ed86d..ffe3674 100644 --- a/src/bin/update_groups.rs +++ b/src/bin/update_groups.rs @@ -1,6 +1,7 @@ use std::collections::HashSet; use sqlx::{Pool, Sqlite}; use std::env; +use dotenv::dotenv; use ldap3::{LdapConn, Mod}; use tide::prelude::*; use skynet_ldap_server::{Config, get_config}; @@ -38,10 +39,16 @@ fn uid_to_dn(uid: &str) -> String{ } async fn update_admin(config: &Config) -> tide::Result<()>{ - let users = vec!["silver", "evanc", "eoghanconlon73"]; - update_group(config,"skynet-admins", &users, true).await?; - // admins automatically get added as users - update_group(config,"skynet-users", &users, false).await?; + dotenv().ok(); + + // read from teh env + if let Ok(x) = env::var("USERS_ADMIN") { + let users = x.split(',').collect::>(); + + update_group(config,"skynet-admins", &users, true).await?; + // admins automatically get added as users + update_group(config,"skynet-users", &users, false).await?; + } Ok(()) }