From f912844aa967db9bd80be1f144a7d6b411c9bfcf Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 20 Oct 2025 11:23:37 -0400 Subject: [PATCH 1/4] tsk-55: Fixing issue with register endpoint --- src/callers/register.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/callers/register.rs b/src/callers/register.rs index bd8711f..565234b 100644 --- a/src/callers/register.rs +++ b/src/callers/register.rs @@ -52,6 +52,7 @@ pub async fn register_user( axum::Extension(pool): axum::Extension, Json(payload): Json, ) -> (StatusCode, Json) { + // TODO: Some cleanup here let mut user = icarus_models::user::User { id: uuid::Uuid::nil(), username: payload.username.clone(), @@ -71,10 +72,10 @@ pub async fn register_user( Ok(res) => { if res { ( - StatusCode::NOT_FOUND, + StatusCode::BAD_REQUEST, Json(response::Response { message: String::from("Error"), - data: vec![user], + data: Vec::new(), }), ) } else { -- 2.43.0 From cf67d37e85692e7f043d9aaa5ad80bd3b8e8496f Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 20 Oct 2025 11:40:32 -0400 Subject: [PATCH 2/4] Tidying up changes --- src/callers/register.rs | 9 +++------ src/repo/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/callers/register.rs b/src/callers/register.rs index 565234b..195e507 100644 --- a/src/callers/register.rs +++ b/src/callers/register.rs @@ -52,9 +52,7 @@ pub async fn register_user( axum::Extension(pool): axum::Extension, Json(payload): Json, ) -> (StatusCode, Json) { - // TODO: Some cleanup here let mut user = icarus_models::user::User { - id: uuid::Uuid::nil(), username: payload.username.clone(), password: payload.password.clone(), email: payload.email.clone(), @@ -63,9 +61,7 @@ pub async fn register_user( lastname: payload.lastname.clone(), status: String::from("Active"), email_verified: true, - date_created: Some(time::OffsetDateTime::now_utc()), - last_login: None, - salt_id: uuid::Uuid::nil(), + ..Default::default() }; match repo::user::exists(&pool, &user.username).await { @@ -90,8 +86,9 @@ pub async fn register_user( user.password = hashed_password; match repo::user::insert(&pool, &user).await { - Ok(id) => { + Ok((id, date_created)) => { user.id = id; + user.date_created = date_created; ( StatusCode::CREATED, Json(response::Response { diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 037ee0f..53fe607 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -94,7 +94,7 @@ pub mod user { pub async fn insert( pool: &sqlx::PgPool, user: &icarus_models::user::User, - ) -> Result { + ) -> Result<(uuid::Uuid, std::option::Option), sqlx::Error> { let row = sqlx::query( r#" INSERT INTO "user" (username, password, email, phone, firstname, lastname, email_verified, status, salt_id) @@ -124,8 +124,8 @@ pub mod user { .map_err(|_e| sqlx::Error::RowNotFound)?, }; - if !result.id.is_nil() { - Ok(result.id) + if !result.id.is_nil() && !result.date_created.is_none() { + Ok((result.id, result.date_created)) } else { Err(sqlx::Error::RowNotFound) } -- 2.43.0 From f52b3a216761fc76d916b185a9c9485676d522c6 Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 20 Oct 2025 11:42:19 -0400 Subject: [PATCH 3/4] tsk-55: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e697009..14f7b71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -748,7 +748,7 @@ dependencies = [ [[package]] name = "icarus_auth" -version = "0.6.1" +version = "0.6.2" dependencies = [ "argon2", "axum", diff --git a/Cargo.toml b/Cargo.toml index 12b7b27..928d972 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus_auth" -version = "0.6.1" +version = "0.6.2" edition = "2024" rust-version = "1.90" -- 2.43.0 From 646b15938d347aa6e82c8f55d222d60ca6f53d8d Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 20 Oct 2025 11:54:43 -0400 Subject: [PATCH 4/4] Wanring fix --- src/repo/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 53fe607..d539517 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -124,10 +124,10 @@ pub mod user { .map_err(|_e| sqlx::Error::RowNotFound)?, }; - if !result.id.is_nil() && !result.date_created.is_none() { - Ok((result.id, result.date_created)) - } else { + if result.id.is_nil() && result.date_created.is_none() { Err(sqlx::Error::RowNotFound) + } else { + Ok((result.id, result.date_created)) } } } -- 2.43.0