mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-20 16:44:38 +08:00
fix: resolve issue with logout functionality in Console not working (#6766)
#### What type of PR is this? /area ui /kind bug /milestone 2.20.x #### What this PR does / why we need it: 修复 Console 中退出登录功能失效的问题。 #### Which issue(s) this PR fixes: Fixes #6756 #### Does this PR introduce a user-facing change? ```release-note None ```
This commit is contained in:
@@ -17,7 +17,6 @@ import {
|
||||
VTag,
|
||||
} from "@halo-dev/components";
|
||||
import { useEventListener } from "@vueuse/core";
|
||||
import axios from "axios";
|
||||
import {
|
||||
useOverlayScrollbars,
|
||||
type UseOverlayScrollbarsParams,
|
||||
@@ -42,24 +41,11 @@ const { currentRoles, currentUser } = storeToRefs(userStore);
|
||||
const handleLogout = () => {
|
||||
Dialog.warning({
|
||||
title: t("core.sidebar.operations.logout.title"),
|
||||
description: t("core.sidebar.operations.logout.description"),
|
||||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await axios.post(`/logout`, undefined, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
await userStore.fetchCurrentUser();
|
||||
|
||||
// Clear csrf token
|
||||
document.cookie =
|
||||
"XSRF-TOKEN=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
||||
|
||||
window.location.href = "/login";
|
||||
} catch (error) {
|
||||
console.error("Failed to logout", error);
|
||||
}
|
||||
window.location.href = "/logout";
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user