From 9fb29bba44eac167ff870c8ce3f9b68e7b44f703 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 8 Feb 2023 00:01:50 +0200 Subject: [PATCH] bugfix --- src/App.js | 2 +- src/structures/PrivateRoute.js | 6 ++---- src/util/Util.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 72a2d5e..d86702b 100644 --- a/src/App.js +++ b/src/App.js @@ -9,7 +9,7 @@ import UserControls from './components/UserControls'; import { useLoginContext } from './structures/UserContext'; import Login from './pages/Login'; import { get, setSession, setSettings } from './util/Util'; -import PrivateRoute from './structures/PrivateRoute'; +import { PrivateRoute } from './structures/PrivateRoute'; import { UnauthedRoute } from './structures/UnauthedRoute'; import Users from './pages/Users'; import Admin from './pages/Admin'; diff --git a/src/structures/PrivateRoute.js b/src/structures/PrivateRoute.js index 177d44b..8904acb 100644 --- a/src/structures/PrivateRoute.js +++ b/src/structures/PrivateRoute.js @@ -2,11 +2,9 @@ import React from 'react'; import { Navigate, useLocation } from "react-router-dom"; import { getUser } from "../util/Util"; -const PrivateRoute = ({ children }) => { +export const PrivateRoute = ({ children }) => { const user = getUser(); const location = useLocation(); if (!user) return ; return children; -}; - -export default PrivateRoute; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/util/Util.js b/src/util/Util.js index b69c80f..2a6f4f0 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -46,7 +46,7 @@ const parseResponse = async (response) => { if (status === 401) { clearSession(); - if(!location.pathname.includes('/login')) location.pathname = '/login'; + if(!location.pathname.includes('/login') && !location.pathname.includes('/register')) location.pathname = '/login'; } if (headers['content-type']?.includes('application/json')) {