feat: log staff sign-in and sign-out and force logout at a set time

This commit is contained in:
2026-10-19 13:34:55 +03:30
parent 3863c5e7d1
commit 8590579605
25 changed files with 588 additions and 15 deletions
+9 -2
View File
@@ -29,13 +29,20 @@ api.interceptors.response.use(
if (path.startsWith('/p/') || path.startsWith('/adm')) {
return Promise.reject(error);
}
const raw = (error.response.data as { message?: string | string[] } | undefined)?.message;
const text = Array.isArray(raw) ? raw.join(' ') : String(raw ?? '');
const hours = text.includes('ساعت کاری');
localStorage.removeItem('mento_token');
localStorage.removeItem('mento_user');
localStorage.removeItem('ment_token');
localStorage.removeItem('ment_user');
if (!path.startsWith('/login')) {
const redirect = encodeURIComponent(path + window.location.search);
window.location.assign(`/login?redirect=${redirect}`);
if (hours) {
window.location.assign('/login?reason=hours');
} else {
const redirect = encodeURIComponent(path + window.location.search);
window.location.assign(`/login?redirect=${redirect}`);
}
}
}
return Promise.reject(error);