- updates and fixes;

This commit is contained in:
Vitalii Kiiko
2024-09-03 17:24:41 +02:00
parent 429ca3c1d1
commit 949ff95933
21 changed files with 342 additions and 117 deletions

View File

@@ -1,16 +1,10 @@
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
// store
import { useStore } from '../../store';
// tools
import AuthenticationService from '../../service/authentication-service';
const ProtectedRoute = () => {
// we need this to track existance of the token
const token = useStore().main.token();
if (!AuthenticationService.wasLoggedIn()) {
return (<Navigate to={'/login'} replace/>);
}
@@ -23,9 +17,9 @@ const ProtectedRoute = () => {
return (<Navigate to={'/login?redirectReason=auth_required'} replace/>);
}
/*if (window.location.pathname === '/') {
if (window.location.pathname === '/') {
return (<Navigate to={'/'} replace/>);
}*/
}
return <Outlet/>;
}