- initial;

This commit is contained in:
Vitalii Kiiko
2024-08-09 08:51:20 +02:00
commit 987b1b0110
46 changed files with 30261 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
// tools
import AuthenticationService from '../../service/authentication-service';
const ProtectedRoute = () => {
if (!AuthenticationService.wasLoggedIn()) {
return (<Navigate to={'/login'} replace/>);
}
if (AuthenticationService.isExpired()) {
return (<Navigate to={'/login?redirectReason=expired'} replace/>);
}
if (!AuthenticationService.isLoggedIn()) {
return (<Navigate to={'/login?redirectReason=auth_required'} replace/>);
}
if (window.location.pathname === '/') {
return (<Navigate to={'/pages/dashboard'} replace/>);
}
return <Outlet/>;
}
export default ProtectedRoute;