fix(web): always use cookie from root

This commit is contained in:
əlemi 2024-07-15 22:52:12 +02:00
parent 9d2996dece
commit 87144b25eb
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 17 additions and 13 deletions

11
Cargo.lock generated
View file

@ -1899,15 +1899,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "jsonvec"
version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.71",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
@ -4791,7 +4782,6 @@ dependencies = [
"hmac",
"httpsign",
"jrd",
"jsonvec",
"nodeinfo",
"openssl",
"reqwest",
@ -4887,6 +4877,7 @@ dependencies = [
"apb",
"chrono",
"console_error_panic_hook",
"cookie",
"dashmap",
"futures",
"jrd",

View file

@ -13,6 +13,7 @@ repository = "https://git.alemi.dev/upub.git"
[dependencies]
lazy_static = "1.4"
cookie = "0.18"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-subscriber-wasm = "0.1"

View file

@ -3,7 +3,7 @@ use leptos_router::*;
use crate::prelude::*;
use crate::CONTACT;
use leptos_use::{signal_debounced, storage::use_local_storage, use_cookie, use_element_size, use_window_scroll, utils::{FromToStringCodec, JsonCodec}, UseElementSizeReturn};
use leptos_use::{signal_debounced, storage::use_local_storage, use_cookie_with_options, use_element_size, use_window_scroll, UseCookieOptions, utils::{FromToStringCodec, JsonCodec}, UseElementSizeReturn};
#[derive(Clone, Copy)]
pub struct Feeds {
@ -44,8 +44,20 @@ impl Feeds {
#[component]
pub fn App() -> impl IntoView {
let (token, set_token) = use_cookie::<String, FromToStringCodec>("token");
let (userid, set_userid) = use_cookie::<String, FromToStringCodec>("user_id");
let (token, set_token) = use_cookie_with_options::<String, FromToStringCodec>(
"token",
UseCookieOptions::default()
.same_site(cookie::SameSite::Strict)
// .secure(true)
.path("/")
);
let (userid, set_userid) = use_cookie_with_options::<String, FromToStringCodec>(
"user_id",
UseCookieOptions::default()
.same_site(cookie::SameSite::Strict)
// .secure(true)
.path("/")
);
let (config, set_config, _) = use_local_storage::<crate::Config, JsonCodec>("config");
let auth = Auth { token, userid };