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