diff --git a/backend/src/services/ron/mod.rs b/backend/src/services/ron/mod.rs index 672464e..32995b0 100644 --- a/backend/src/services/ron/mod.rs +++ b/backend/src/services/ron/mod.rs @@ -30,14 +30,13 @@ pub async fn set_lang( let mut jar = CookieJar::from_headers(&headers); if let Some(user) = context.user { connection.set_user_lang(user.id, &ron.lang).await?; + } else { + // Only set the cookie if the user is not connected. + let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)) + .same_site(SameSite::Lax) + .path("/"); + jar = jar.add(cookie); } - - // Always set the cookie even is the user is connected in case of disconnection. - let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)) - .same_site(SameSite::Lax) - .path("/"); - jar = jar.add(cookie); - Ok((jar, StatusCode::OK)) }