more cleanup
This commit is contained in:
parent
46232b4254
commit
79ecd74500
1 changed files with 7 additions and 3 deletions
10
src/users.rs
10
src/users.rs
|
@ -8,7 +8,6 @@ use axum::{
|
|||
response::IntoResponse,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
use tracing::log::log;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -17,6 +16,7 @@ use crate::templates::CreateUser;
|
|||
const CREATE_QUERY: &str =
|
||||
"insert into witches (id, username, displayname, email, pwhash) values ($1, $2, $3, $4, $5)";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct User {
|
||||
id: Uuid,
|
||||
username: String,
|
||||
|
@ -45,13 +45,16 @@ impl From<DbUser> for User {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get Handler: displays the form to create a user
|
||||
pub async fn get_create_user() -> CreateUser {
|
||||
CreateUser::default()
|
||||
}
|
||||
|
||||
/// Post Handler: validates form values and calls the actual, private user
|
||||
/// creation function
|
||||
#[axum::debug_handler]
|
||||
pub async fn post_create_user(
|
||||
State(pool): State<sqlx::SqlitePool>,
|
||||
State(pool): State<SqlitePool>,
|
||||
Form(signup): Form<CreateUser>,
|
||||
) -> Result<(), CreateUserError> {
|
||||
let username = &signup.username;
|
||||
|
@ -97,7 +100,8 @@ pub async fn post_create_user(
|
|||
};
|
||||
let email = &email;
|
||||
|
||||
let _ = create_user(username, displayname, email, password, &pool).await?;
|
||||
let user = create_user(username, displayname, email, password, &pool).await?;
|
||||
tracing::debug!("created {user:?}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue