From 5febdad57493e142b199ed6fe0d5d81a380ff34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Frnka?= Date: Sun, 14 Apr 2024 22:40:06 +0200 Subject: [PATCH] SMA-80: changing navbar and private route to handle 401 --- frontend/sportsmatch-app/src/components/Navbar.tsx | 2 +- frontend/sportsmatch-app/src/components/PrivateRoute.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/sportsmatch-app/src/components/Navbar.tsx b/frontend/sportsmatch-app/src/components/Navbar.tsx index c317fa2d..3e53154d 100644 --- a/frontend/sportsmatch-app/src/components/Navbar.tsx +++ b/frontend/sportsmatch-app/src/components/Navbar.tsx @@ -19,7 +19,7 @@ function Navbar() { setLoggedIn(true) } catch (error) { const code = (error as ApiError).status - if (code === 400) { + if (code === 401) { localStorage.removeItem('token') setLoggedIn(false) } diff --git a/frontend/sportsmatch-app/src/components/PrivateRoute.tsx b/frontend/sportsmatch-app/src/components/PrivateRoute.tsx index 37f930bb..9a12b389 100644 --- a/frontend/sportsmatch-app/src/components/PrivateRoute.tsx +++ b/frontend/sportsmatch-app/src/components/PrivateRoute.tsx @@ -20,7 +20,7 @@ const PrivateRoute = () => { await ExSecuredEndpointService.getUserMainPage() } catch (error) { const code = (error as ApiError).status - if (code === 400) { + if (code === 401) { localStorage.removeItem('token') setAuthorized(false) }