From 114367d03a0909a643f66d587bf705c4950a3e4b Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 18 Jun 2023 18:29:49 +0100 Subject: [PATCH] feat: now get the users from teh env --- src/bin/update_groups.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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(()) }