fix: use modules to better organise teh code
This commit is contained in:
parent
263a5b76e1
commit
158292be05
2 changed files with 186 additions and 178 deletions
|
@ -1,6 +1,9 @@
|
||||||
use skynet_ldap_backend::{
|
use skynet_ldap_backend::{
|
||||||
db_init, get_config,
|
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,
|
State,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +24,8 @@ async fn main() -> tide::Result<()> {
|
||||||
let mut app = tide::with_state(state);
|
let mut app = tide::with_state(state);
|
||||||
|
|
||||||
app.at("/ldap/update").post(post_update_ldap);
|
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?;
|
app.listen(host_port).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -232,7 +232,9 @@ pub mod post {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
pub mod account {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct LdapNewUser {
|
struct LdapNewUser {
|
||||||
|
@ -244,7 +246,7 @@ struct LdapNewUser {
|
||||||
/// Handles initial detail entering page
|
/// Handles initial detail entering page
|
||||||
/// Verify users have access to said email
|
/// Verify users have access to said email
|
||||||
/// Get users to set username and password.
|
/// 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 {
|
let LdapNewUser {
|
||||||
auth,
|
auth,
|
||||||
user,
|
user,
|
||||||
|
@ -452,3 +454,5 @@ async fn account_verification_clear_pending(db: &Pool<Sqlite>, auth_code: &str)
|
||||||
.fetch_all(db)
|
.fetch_all(db)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue