updates on the build
This commit is contained in:
@@ -17,20 +17,27 @@ import { useDispatch, useSelector } from 'react-redux';
|
||||
// ==============================|| APP - THEME, ROUTER, LOCAL ||============================== //
|
||||
|
||||
const SESSION_CLEAR_INTERVAL_MS = 30 * 60 * 1000;
|
||||
const SESSION_CHECK_INTERVAL_MS = 10000; // Check every 10 seconds
|
||||
|
||||
const App = () => {
|
||||
let navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
if (!localStorage.getItem('authname')) {
|
||||
navigate('/login');
|
||||
} else if (!localStorage.getItem('sessionStartTime')) {
|
||||
localStorage.setItem('sessionStartTime', String(Date.now()));
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
if (!localStorage.getItem('authname')) return;
|
||||
const sessionStart = Number(localStorage.getItem('sessionStartTime')) || Date.now();
|
||||
if (Date.now() - sessionStart >= SESSION_CLEAR_INTERVAL_MS) {
|
||||
localStorage.clear();
|
||||
navigate('/login');
|
||||
}, SESSION_CLEAR_INTERVAL_MS);
|
||||
}
|
||||
}, SESSION_CHECK_INTERVAL_MS);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
const { openItem } = useSelector((state) => state.menu);
|
||||
|
||||
@@ -64,6 +64,7 @@ const Profile = () => {
|
||||
localStorage.removeItem('authname');
|
||||
localStorage.removeItem('roleid');
|
||||
localStorage.removeItem('tenantid');
|
||||
localStorage.removeItem('sessionStartTime');
|
||||
localStorage.clear();
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ const Login = () => {
|
||||
localStorage.setItem('locationid', d.locationid);
|
||||
localStorage.setItem('moduleid', d.moduleid);
|
||||
localStorage.setItem('userid', d.userid);
|
||||
localStorage.setItem('sessionStartTime', String(Date.now()));
|
||||
|
||||
setSubmitting(false);
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user