From 9c591af773c25de001d5ecb46e6c5b4f88df0248 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 11 Nov 2026 11:52:43 -0500 Subject: [PATCH] tsk-14: One last thing --- src/callers/login.rs | 47 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/callers/login.rs b/src/callers/login.rs index 5f89f72..e09c29c 100644 --- a/src/callers/login.rs +++ b/src/callers/login.rs @@ -508,27 +508,34 @@ pub mod endpoint { Ok(user) => { let firstname = payload.firstname; let lastname = payload.lastname; - match repo::user::update_user_profile(&pool, &user_id, &firstname, &lastname) + + if firstname == user.firstname && lastname == user.lastname { + (axum::http::StatusCode::NOT_MODIFIED, axum::Json(response)) + } else { + match repo::user::update_user_profile( + &pool, &user_id, &firstname, &lastname, + ) .await - { - Ok(_) => { - let user_profile = simodels::user::UserProfile { - firstname, - lastname, - username: user.username, - email: user.email, - }; - response.message = "SUCCESSFUL".to_string(); - response.data.push(user_profile); - (axum::http::StatusCode::OK, axum::Json(response)) - } - Err(err) => { - eprintln!("Error: {err:?}"); - response.message = "ERROR - Updating user profile".to_string(); - ( - axum::http::StatusCode::INTERNAL_SERVER_ERROR, - axum::Json(response), - ) + { + Ok(_) => { + let user_profile = simodels::user::UserProfile { + firstname, + lastname, + username: user.username, + email: user.email, + }; + response.message = "SUCCESSFUL".to_string(); + response.data.push(user_profile); + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + eprintln!("Error: {err:?}"); + response.message = "ERROR - Updating user profile".to_string(); + ( + axum::http::StatusCode::INTERNAL_SERVER_ERROR, + axum::Json(response), + ) + } } } }