ferat: add new users to teh local db
This commit is contained in:
parent
36b13fb1f2
commit
869e7bc91b
1 changed files with 17 additions and 2 deletions
|
@ -197,7 +197,7 @@ pub async fn post_new_account_confirmation(mut req: Request<State>) -> tide::Res
|
|||
|
||||
let AccountsPending{ user, mail, name_first, name_second, auth_code, expiry } = &results[0];
|
||||
let dn = format!("uid={},ou=users,dc=skynet,dc=ie", user);
|
||||
let uid_number = get_max_uid_number(db).await.to_string();
|
||||
let uid_number = get_max_uid_number(db).await;
|
||||
let home_directory = format!("/home/{}", user);
|
||||
let password_tmp = create_random_string(50);
|
||||
let cn = format!("{} {}", name_first, name_second);
|
||||
|
@ -217,7 +217,7 @@ pub async fn post_new_account_confirmation(mut req: Request<State>) -> tide::Res
|
|||
("cn", HashSet::from([cn.as_str()])),
|
||||
|
||||
// posixaccount
|
||||
("uidNumber", HashSet::from([uid_number.as_str()])),
|
||||
("uidNumber", HashSet::from([uid_number.to_string().as_str()])),
|
||||
("gidNumber", HashSet::from(["1001"])),
|
||||
("homedirectory", HashSet::from([home_directory.as_str()])),
|
||||
("userpassword", HashSet::from([password_tmp.as_str()])),
|
||||
|
@ -255,6 +255,21 @@ pub async fn post_new_account_confirmation(mut req: Request<State>) -> tide::Res
|
|||
println!("{:?}", results)
|
||||
}
|
||||
|
||||
// add new users to teh local database
|
||||
sqlx::query_as::<_, Accounts>(
|
||||
"
|
||||
INSERT OR REPLACE INTO accounts (user, uid_number, enabled)
|
||||
VALUES (?1, ?2, ?3)
|
||||
",
|
||||
)
|
||||
.bind(&user)
|
||||
.bind(&uid_number)
|
||||
.bind(false)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
|
||||
// frontend tells user that initial password ahs been sent to tehm
|
||||
Ok(json!({"result": "success"}).into())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue