1
0
Fork 0
forked from alemi/upub

fix(web): play it safe and update auth immediately

This commit is contained in:
əlemi 2024-04-18 05:00:26 +02:00
parent 85f3bc1e5c
commit 96e3681bf7
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -51,7 +51,10 @@ pub fn LoginBox(
.json::<AuthResponse>() .json::<AuthResponse>()
.await.unwrap(); .await.unwrap();
logging::log!("logged in until {}", auth.expires); logging::log!("logged in until {}", auth.expires);
// update our username and token cookies
let username = auth.user.split('/').last().unwrap_or_default().to_string(); let username = auth.user.split('/').last().unwrap_or_default().to_string();
username_tx.set(Some(username.clone()));
token_tx.set(Some(auth.token));
// reset home feed and point it to our user's inbox // reset home feed and point it to our user's inbox
home_tl.reset(format!("{URL_BASE}/users/{}/inbox/page", username)); home_tl.reset(format!("{URL_BASE}/users/{}/inbox/page", username));
spawn_local(async move { spawn_local(async move {
@ -66,9 +69,6 @@ pub fn LoginBox(
tracing::error!("failed refreshing server timeline: {e}"); tracing::error!("failed refreshing server timeline: {e}");
} }
}); });
// update our username and token cookies
username_tx.set(Some(username));
token_tx.set(Some(auth.token));
}); });
} /> } />
</div> </div>