Compare commits

..
Author SHA1 Message Date
phoenix e82a62dec4 tsk-14: Update user profile (#15)
Release Tagging / release (push) Successful in 16s
soaricarus_auth Build / build (push) Successful in 1m5s
soaricarus_auth Build / Rustfmt (push) Successful in 1m10s
soaricarus_auth Build / Check (push) Successful in 1m16s
soaricarus_auth Build / Clippy (push) Successful in 1m19s
soaricarus_auth Build / Test Suite (push) Successful in 1m19s
Closes #14

Reviewed-on: http://git.kundeng.us/phoenix/soaricarus_auth/pulls/15
2026-11-11 13:13:49 -05:00
3 changed files with 30 additions and 26 deletions

No files matched your search

+27 -20
View File
@@ -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),
)
}
}
}
}
-1
View File
@@ -124,7 +124,6 @@ pub mod init {
put(callers::login::endpoint::update_user_profile),
)
.layer(cors::configure_cors().await)
.layer(cors::configure_cors().await)
}
pub async fn app() -> Router {
+3 -5
View File
@@ -1,5 +1,4 @@
use soaricarus_auth;
use soaricarus_auth::init;
use soaricarus_auth::{config, init};
#[tokio::main]
async fn main() {
@@ -9,7 +8,7 @@ async fn main() {
let app = init::app().await;
// run our app with hyper, listening globally on port 8001
let url = soaricarus_auth::config::get_full();
let url = config::get_full();
let listener = tokio::net::TcpListener::bind(url).await.unwrap();
axum::serve(listener, app).await.unwrap();
}
@@ -18,8 +17,7 @@ async fn main() {
mod tests {
use super::*;
use soaricarus_auth;
use soaricarus_auth::callers;
use soaricarus_auth::db;
use soaricarus_auth::{callers, db};
use axum::{
body::Body,