feat: implement server restart functionality and refactor logout handling
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user