From d1e7d7bf27e25405b6fcdd485e5aa1a3aeb46265 Mon Sep 17 00:00:00 2001
From: jdlugosz963 <jdlugosz963@gmail.com>
Date: Tue, 9 Nov 2021 22:24:46 +0100
Subject: Add login system

---
 src/views/Home.vue | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 src/views/Home.vue

(limited to 'src/views/Home.vue')

diff --git a/src/views/Home.vue b/src/views/Home.vue
new file mode 100644
index 0000000..e5b446b
--- /dev/null
+++ b/src/views/Home.vue
@@ -0,0 +1,30 @@
+<template>
+  <div class="home">
+    Hi {{get_username}}!
+    <input type="button" value="Logout!" @click="logout">
+  </div>
+</template>
+
+<script>
+export default {
+  methods: {
+    logout() {
+      this.$store.dispatch('logout')
+      this.$router.push('/login')
+    }
+  },
+
+  computed: {
+    get_username() {
+      return this.$store.getters.get_user.username
+    }
+  },
+
+  created() {
+    if(!this.$store.getters['is_logged_in']) {
+      this.$router.push('/login')
+    }
+  }
+  
+}
+</script>
-- 
cgit v1.2.3

