Compare commits

..

No commits in common. "004f745bc0f1fdf2ba1ae17c66d63ccc505fb4b1" and "d7d7d84150c3db195d6e827a9d73824c39d4ec4d" have entirely different histories.

3 changed files with 6 additions and 4 deletions

View File

@ -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';

View File

@ -2,9 +2,11 @@ import React from 'react';
import { Navigate, useLocation } from "react-router-dom";
import { getUser } from "../util/Util";
export const PrivateRoute = ({ children }) => {
const PrivateRoute = ({ children }) => {
const user = getUser();
const location = useLocation();
if (!user) return <Navigate to='/login' replace state={{ from: location }} />;
return children;
};
export default PrivateRoute;

View File

@ -46,7 +46,7 @@ const parseResponse = async (response) => {
if (status === 401) {
clearSession();
if(!location.pathname.includes('/login') && !location.pathname.includes('/register')) location.pathname = '/login';
if(!location.pathname.includes('/login')) location.pathname = '/login';
}
if (headers['content-type']?.includes('application/json')) {