From a7c9193a8645f075b3404d4e0b36ee22d5fcaaf3 Mon Sep 17 00:00:00 2001
From: Santo Cariotti <santo@dcariotti.me>
Date: Wed, 14 Sep 2022 19:13:05 +0200
Subject: Logout

---
 components/VHeader.vue | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'components/VHeader.vue')

diff --git a/components/VHeader.vue b/components/VHeader.vue
index a9b85ff..13b8919 100644
--- a/components/VHeader.vue
+++ b/components/VHeader.vue
@@ -32,7 +32,7 @@
               .absolute.right-0.z-10.mt-2.w-48.origin-top-right.rounded-md.bg-white.py-1.shadow-lg.ring-1.ring-black.ring-opacity-5(class="focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1" v-if="boxUserInfo")
                 a#user-menu-item-0.block.px-4.py-2.text-sm.text-gray-700(href="#" role="menuitem" tabindex="-1") Your Profile
                 a#user-menu-item-1.block.px-4.py-2.text-sm.text-gray-700(href="#" role="menuitem" tabindex="-1") Settings
-                a#user-menu-item-2.block.px-4.py-2.text-sm.text-gray-700(href="#" role="menuitem" tabindex="-1") Sign out
+                a#user-menu-item-2.block.px-4.py-2.text-sm.text-gray-700(href="#" role="menuitem" tabindex="-1" @click="logout") Sign out
           .absolute.inset-y-0.right-0.flex.items-center.pr-2(class="sm:static sm:inset-auto sm:ml-6 sm:pr-0" v-else)
             a(href="/signin")
               button.text-white Entra
@@ -47,7 +47,7 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex";
+import { mapGetters, mapActions } from "vuex";
 
 export default {
   name: "VHeader",
@@ -70,5 +70,11 @@ export default {
       this.$store.dispatch("auth/findMe");
     }
   },
+  methods: {
+    logout() {
+      this.$store.dispatch("auth/logout");
+      window.location.href = "/";
+    },
+  },
 };
 </script>
-- 
cgit v1.2.3-71-g8e6c

