next/server/api/auth/logout.post.ts

11 lines
255 B
TypeScript
Raw Normal View History

export default eventHandler(async (ev) => {
if (ev.context.currentUser) {
deleteCookie(ev, "auth:token");
ev.context.currentUser = undefined;
return {
success: true,
};
}
throw createError({ statusCode: 400, message: "Not logged in" });
});