Update dependencies, add translation endpoint, and display a user message when logged in
This commit is contained in:
parent
6b043620b8
commit
348b0f24e9
19 changed files with 170 additions and 34 deletions
|
|
@ -1,13 +1,18 @@
|
|||
use axum::{
|
||||
debug_handler,
|
||||
extract::{Extension, State},
|
||||
extract::{Extension, Query, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{IntoResponse, Result},
|
||||
};
|
||||
use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
|
||||
use common::ron_api;
|
||||
|
||||
use crate::{
|
||||
app::Context, consts, data::db, data::model, ron_extractor::ExtractRon, ron_utils::ron_error,
|
||||
app::Context,
|
||||
consts,
|
||||
data::{db, model},
|
||||
ron_extractor::ExtractRon,
|
||||
ron_utils::{ron_error, ron_response_ok},
|
||||
};
|
||||
|
||||
pub mod calendar;
|
||||
|
|
@ -36,6 +41,16 @@ pub async fn set_lang(
|
|||
Ok((jar, StatusCode::OK))
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn get_translation(
|
||||
Extension(context): Extension<Context>,
|
||||
translation_id: Query<ron_api::Id>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
Ok(ron_response_ok(ron_api::Value {
|
||||
value: context.tr.t_from_id(translation_id.id),
|
||||
}))
|
||||
}
|
||||
|
||||
/*** 404 ***/
|
||||
|
||||
#[debug_handler]
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub async fn get(
|
|||
pub async fn set_entry_checked(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(context): Extension<Context>,
|
||||
ExtractRon(ron): ExtractRon<ron_api::Value<bool>>,
|
||||
ExtractRon(ron): ExtractRon<ron_api::KeyValue<bool>>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
check_user_rights_shopping_list_entry(&connection, &context.user, ron.id).await?;
|
||||
Ok(ron_response_ok(
|
||||
|
|
|
|||
|
|
@ -367,7 +367,15 @@ pub async fn sign_in_post(
|
|||
.same_site(cookie::SameSite::Strict);
|
||||
Ok((
|
||||
jar.add(cookie),
|
||||
Redirect::to(&format!("/{}/", context.tr.current_lang_code())).into_response(),
|
||||
Redirect::to(&format!(
|
||||
"/{}/?{}={}&{}={}",
|
||||
context.tr.current_lang_code(),
|
||||
common::consts::GET_PARAMETER_USER_MESSAGE,
|
||||
Sentence::SignInSuccess as i64,
|
||||
common::consts::GET_PARAMETER_USER_MESSAGE_LEVEL,
|
||||
common::toast::Level::Success as usize
|
||||
))
|
||||
.into_response(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue