You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
726 B
28 lines
726 B
import { logoutUser } from "../../service/auth";
|
|
|
|
const SESSION_COOKIE_NAME = "pp_session";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
try {
|
|
const sessionId = getCookie(event, SESSION_COOKIE_NAME);
|
|
if (sessionId) {
|
|
await logoutUser(sessionId);
|
|
}
|
|
|
|
deleteCookie(event, SESSION_COOKIE_NAME, {
|
|
path: "/",
|
|
});
|
|
|
|
return R.success({
|
|
success: true,
|
|
});
|
|
} catch (err) {
|
|
if (err && typeof err === "object" && "statusCode" in err) {
|
|
throw err;
|
|
}
|
|
throw createError({
|
|
statusCode: 500,
|
|
statusMessage: "服务器繁忙,请稍后重试",
|
|
});
|
|
}
|
|
});
|
|
|