From 7678a44945ddc542f1a772f7d558fe57f24e9004 Mon Sep 17 00:00:00 2001 From: Xeovalyte Date: Mon, 26 Jun 2023 15:16:24 +0200 Subject: [PATCH] feat: Added logout function --- webv2/components/body/Sidebar.vue | 20 +++++++++++++++++++ webv2/server/api/auth/index.delete.ts | 4 ++++ .../server/api/{auth.ts => auth/index.get.ts} | 0 3 files changed, 24 insertions(+) create mode 100644 webv2/server/api/auth/index.delete.ts rename webv2/server/api/{auth.ts => auth/index.get.ts} (100%) diff --git a/webv2/components/body/Sidebar.vue b/webv2/components/body/Sidebar.vue index 5665e67..5eec4fa 100644 --- a/webv2/components/body/Sidebar.vue +++ b/webv2/components/body/Sidebar.vue @@ -15,5 +15,25 @@ Map +
+ + Logout +
+ + diff --git a/webv2/server/api/auth/index.delete.ts b/webv2/server/api/auth/index.delete.ts new file mode 100644 index 0000000..3e3525b --- /dev/null +++ b/webv2/server/api/auth/index.delete.ts @@ -0,0 +1,4 @@ +export default defineEventHandler((event) => { + setCookie(event, 'jwt', '', { httpOnly: true, maxAge: 1 }) + sendRedirect(event, '/', 302) +}) diff --git a/webv2/server/api/auth.ts b/webv2/server/api/auth/index.get.ts similarity index 100% rename from webv2/server/api/auth.ts rename to webv2/server/api/auth/index.get.ts