feat: now get the users from teh env

This commit is contained in:
silver 2023-06-18 18:29:49 +01:00
parent ff282e823b
commit 114367d03a

View file

@ -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::<Vec<&str>>();
update_group(config,"skynet-admins", &users, true).await?;
// admins automatically get added as users
update_group(config,"skynet-users", &users, false).await?;
}
Ok(())
}