diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-10-14 19:07:14 -0400 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-10-14 19:07:14 -0400 |
commit | 58f91c62065d9a7e37c953503100b87b506297e7 (patch) | |
tree | 9e43fb45702d06366af015151f8ea4613e46e08a /webapp/src/components | |
parent | 1e0ceb4b7c714430ff42a1c98d416246f035d75f (diff) |
Automatically log in again when token refresh fails
Diffstat (limited to 'webapp/src/components')
-rw-r--r-- | webapp/src/components/app_context_provider.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/webapp/src/components/app_context_provider.rs b/webapp/src/components/app_context_provider.rs index 50e4e1a..e3fe82e 100644 --- a/webapp/src/components/app_context_provider.rs +++ b/webapp/src/components/app_context_provider.rs @@ -20,7 +20,11 @@ pub struct Props { } async fn initialize_context() -> Result<AppContext, anyhow::Error> { - let user = Request::get("/api/user/info").send().await?.json().await?; + let response = Request::get("/api/user/info").send().await?; + if response.status() == 401 { + web_sys::window().unwrap().location().assign("/api/login").unwrap(); + }; + let user = response.json().await?; Ok(AppContext { user: user, error: None, |