feat: log staff sign-in and sign-out and force logout at a set time
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user