Files
frontend/src/utils/session.js
T

24 lines
472 B
JavaScript

import { authApi } from '../api/index.js';
import { deleteCookie as removeCookie } from './functions.js';
async function handleLogout(router) {
try {
await authApi.logout();
} catch (error) {
console.error('Logout API error:', error);
}
removeCookie('token');
removeCookie('username');
removeCookie('user-type');
removeCookie('user-id');
if (router) {
router.push('/login');
}
}
export {
handleLogout
};