* Create a minimalistic toast
* Profile editing (WIP)
This commit is contained in:
parent
327b2d0a5b
commit
1c79cc890d
25 changed files with 1133 additions and 575 deletions
|
|
@ -46,21 +46,15 @@
|
|||
// #[put("/ron-api/recipe/rm-step")]
|
||||
// #[put("/ron-api/recipe/set-steps-order")]
|
||||
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{
|
||||
debug_handler,
|
||||
extract::{Extension, State},
|
||||
http::StatusCode,
|
||||
response::ErrorResponse,
|
||||
response::Result,
|
||||
response::{ErrorResponse, IntoResponse, Result},
|
||||
};
|
||||
use tracing::{event, Level};
|
||||
|
||||
use crate::{
|
||||
data::db,
|
||||
model,
|
||||
ron_extractor::{ron_error, ron_response, ExtractRon},
|
||||
};
|
||||
use crate::{data::db, model, ron_extractor::ExtractRon, ron_utils::ron_error};
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn update_user(
|
||||
|
|
@ -69,7 +63,14 @@ pub async fn update_user(
|
|||
ExtractRon(ron): ExtractRon<common::ron_api::UpdateProfile>,
|
||||
) -> Result<StatusCode> {
|
||||
if let Some(user) = user {
|
||||
// connection.set_user_name(user.id, &ron.name).await?;
|
||||
connection
|
||||
.update_user(
|
||||
user.id,
|
||||
ron.email.as_deref(),
|
||||
ron.name.as_deref(),
|
||||
ron.password.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
return Err(ErrorResponse::from(ron_error(
|
||||
StatusCode::UNAUTHORIZED,
|
||||
|
|
@ -79,17 +80,8 @@ pub async fn update_user(
|
|||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
||||
/* Example with RON return value.
|
||||
///// 404 /////
|
||||
#[debug_handler]
|
||||
pub async fn set_user_name(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
ExtractRon(ron): ExtractRon<common::ron_api::SetProfileName>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
|
||||
|
||||
Ok(ron_response(common::ron_api::SetProfileName {
|
||||
name: "abc".to_string(),
|
||||
}))
|
||||
pub async fn not_found(Extension(user): Extension<Option<model::User>>) -> impl IntoResponse {
|
||||
ron_error(StatusCode::NOT_FOUND, "Not found")
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue