fix: use modules to better organise teh code

This commit is contained in:
silver 2023-08-06 12:43:50 +01:00
parent 263a5b76e1
commit 158292be05
2 changed files with 186 additions and 178 deletions

View file

@ -1,6 +1,9 @@
use skynet_ldap_backend::{
db_init, get_config,
methods::{account_new::post_new_account, account_update::post_update_ldap},
methods::{
account_new::post::{account, email},
account_update::post_update_ldap,
},
State,
};
@ -21,7 +24,8 @@ async fn main() -> tide::Result<()> {
let mut app = tide::with_state(state);
app.at("/ldap/update").post(post_update_ldap);
app.at("/ldap/new").post(post_new_account);
app.at("/ldap/new/email").post(email::submit);
app.at("/ldap/new/account").post(account::submit);
app.listen(host_port).await?;
Ok(())

View file

@ -232,7 +232,9 @@ pub mod post {
.await
}
}
}
pub mod account {
use super::*;
#[derive(Debug, Deserialize)]
struct LdapNewUser {
@ -244,7 +246,7 @@ struct LdapNewUser {
/// Handles initial detail entering page
/// Verify users have access to said email
/// Get users to set username and password.
pub async fn post_new_account(mut req: Request<State>) -> tide::Result {
pub async fn submit(mut req: Request<State>) -> tide::Result {
let LdapNewUser {
auth,
user,
@ -452,3 +454,5 @@ async fn account_verification_clear_pending(db: &Pool<Sqlite>, auth_code: &str)
.fetch_all(db)
.await
}
}
}