From 1c27c7abcf6534f7c0624d12ec5cfadb86923243 Mon Sep 17 00:00:00 2001 From: cdickson Date: Fri, 6 Oct 2023 16:02:15 -0400 Subject: [PATCH] Ensure we login after idle timeouts/on 401s --- packages/client/hmi-client/src/api/api.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/client/hmi-client/src/api/api.ts b/packages/client/hmi-client/src/api/api.ts index 2b81151a5b..6ee3988dc1 100644 --- a/packages/client/hmi-client/src/api/api.ts +++ b/packages/client/hmi-client/src/api/api.ts @@ -40,6 +40,13 @@ API.interceptors.response.use( toastTitle: `${ToastSummaries.NETWORK_ERROR} (${status})` }); } + if (status === 401) { + // redirect to login + const auth = useAuthStore(); + auth.keycloak?.login({ + redirectUri: window.location.href + }); + } return null; } );