feat(api): add api endpoint to log user out
This commit is contained in:
parent
6f770a1cb8
commit
83d1e97f49
10
server/api/auth/logout.post.ts
Normal file
10
server/api/auth/logout.post.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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" });
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user