Add the lang prefix to all links
This commit is contained in:
parent
b39cb1c067
commit
3089ede6eb
7 changed files with 40 additions and 11 deletions
|
|
@ -21,7 +21,12 @@ pub async fn create(
|
|||
) -> Result<Response> {
|
||||
if let Some(user) = user {
|
||||
let recipe_id = connection.create_recipe(user.id).await?;
|
||||
Ok(Redirect::to(&format!("/recipe/edit/{}", recipe_id)).into_response())
|
||||
Ok(Redirect::to(&format!(
|
||||
"/{}/recipe/edit/{}",
|
||||
tr.current_lang_code(),
|
||||
recipe_id
|
||||
))
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(Html(MessageTemplate::new(tr.t(Sentence::NotLoggedIn), tr).render()?).into_response())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,10 @@ pub async fn sign_in_post(
|
|||
)),
|
||||
db::user::SignInResult::Ok(token, _user_id) => {
|
||||
let cookie = Cookie::new(consts::COOKIE_AUTH_TOKEN_NAME, token);
|
||||
Ok((jar.add(cookie), Redirect::to("/").into_response()))
|
||||
Ok((
|
||||
jar.add(cookie),
|
||||
Redirect::to(&format!("/{}/", tr.current_lang_code())).into_response(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -353,6 +356,7 @@ pub async fn sign_in_post(
|
|||
#[debug_handler]
|
||||
pub async fn sign_out(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(tr): Extension<translation::Tr>,
|
||||
req: Request<Body>,
|
||||
) -> Result<(CookieJar, Redirect)> {
|
||||
let mut jar = CookieJar::from_headers(req.headers());
|
||||
|
|
@ -361,7 +365,7 @@ pub async fn sign_out(
|
|||
jar = jar.remove(consts::COOKIE_AUTH_TOKEN_NAME);
|
||||
connection.sign_out(&token).await?;
|
||||
}
|
||||
Ok((jar, Redirect::to("/")))
|
||||
Ok((jar, Redirect::to(&format!("/{}/", tr.current_lang_code()))))
|
||||
}
|
||||
|
||||
/// RESET PASSWORD ///
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
{% match user %}
|
||||
{% when Some with (user) %}
|
||||
<a class="create-recipe" href="/recipe/new" >{{ tr.t(Sentence::CreateNewRecipe) }}</a>
|
||||
<a href="/user/edit">
|
||||
<a href="/{{ tr.current_lang_code() }}/user/edit">
|
||||
{% if user.name == "" %}
|
||||
{{ user.email }}
|
||||
{% else %}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
{% endif %}
|
||||
</a> / <a href="/signout">{{ tr.t(Sentence::SignOut) }}</a>
|
||||
{% when None %}
|
||||
<a href="/signin" >{{ tr.t(Sentence::SignInMenu) }}</a>/<a href="/signup">{{ tr.t(Sentence::SignUpMenu) }}</a>/<a href="/ask_reset_password">{{ tr.t(Sentence::LostPassword) }}</a>
|
||||
<a href="/{{ tr.current_lang_code() }}/signin" >{{ tr.t(Sentence::SignInMenu) }}</a>/<a href="/{{ tr.current_lang_code() }}/signup">{{ tr.t(Sentence::SignUpMenu) }}</a>/<a href="/{{ tr.current_lang_code() }}/ask_reset_password">{{ tr.t(Sentence::LostPassword) }}</a>
|
||||
{% endmatch %}
|
||||
|
||||
<select id="select-website-language">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<div class="content" id="user-edit">
|
||||
<h1>{{ tr.t(Sentence::ProfileTitle) }}</h1>
|
||||
|
||||
<form action="/user/edit" method="post">
|
||||
<form action="/{{ tr.current_lang_code() }}/user/edit" method="post">
|
||||
|
||||
<label for="input-name">{{ tr.t(Sentence::Name) }}</label>
|
||||
<input
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
{% if let Some(user) = user %}
|
||||
{% if crate::data::model::can_user_edit_recipe(user, recipe) %}
|
||||
<a class="edit-recipe" href="/recipe/edit/{{ recipe.id }}" >Edit</a>
|
||||
<a class="edit-recipe" href="/{{ tr.current_lang_code() }}/recipe/edit/{{ recipe.id }}" >Edit</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue