Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
453538582b
|
||
|
|
aa4b7d34db
|
||
|
|
70c64cdaf7
|
||
|
|
5b9b852c8d
|
||
|
|
587405c995
|
No files matched your search
+20
-27
@@ -508,34 +508,27 @@ pub mod endpoint {
|
||||
Ok(user) => {
|
||||
let firstname = payload.firstname;
|
||||
let lastname = payload.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,
|
||||
)
|
||||
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),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ 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 {
|
||||
|
||||
+5
-3
@@ -1,4 +1,5 @@
|
||||
use soaricarus_auth::{config, init};
|
||||
use soaricarus_auth;
|
||||
use soaricarus_auth::init;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -8,7 +9,7 @@ async fn main() {
|
||||
let app = init::app().await;
|
||||
|
||||
// run our app with hyper, listening globally on port 8001
|
||||
let url = config::get_full();
|
||||
let url = soaricarus_auth::config::get_full();
|
||||
let listener = tokio::net::TcpListener::bind(url).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
@@ -17,7 +18,8 @@ async fn main() {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use soaricarus_auth;
|
||||
use soaricarus_auth::{callers, db};
|
||||
use soaricarus_auth::callers;
|
||||
use soaricarus_auth::db;
|
||||
|
||||
use axum::{
|
||||
body::Body,
|
||||
|
||||
Reference in new issue
Block a user