summaryrefslogtreecommitdiffstats
path: root/src/views/Home.vue
blob: e5b446b121aed4f7c5bd66fc6a64bc35ee849178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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>