forked from alemi/upub
fix(web): only refresh if logged in
This commit is contained in:
parent
dfbac324f5
commit
399fdecee7
1 changed files with 20 additions and 18 deletions
|
@ -12,10 +12,11 @@ pub fn App() -> impl IntoView {
|
|||
let (userid, set_userid) = use_cookie::<String, FromToStringCodec>("user_id");
|
||||
let (config, set_config, _) = use_local_storage::<crate::Config, JsonCodec>("config");
|
||||
|
||||
if let Some(tok) = token.get_untracked() {
|
||||
spawn_local(async move {
|
||||
match reqwest::Client::new()
|
||||
.request(Method::PATCH, format!("{URL_BASE}/auth"))
|
||||
.json(&serde_json::json!({"token": token.get().unwrap_or_default()}))
|
||||
.json(&serde_json::json!({"token": tok}))
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
|
@ -31,7 +32,8 @@ pub fn App() -> impl IntoView {
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
let auth = Auth { token, userid };
|
||||
provide_context(auth);
|
||||
|
|
Loading…
Reference in a new issue