Skip to content

Commit

Permalink
Logging user out
Browse files Browse the repository at this point in the history
  • Loading branch information
palashmon committed May 28, 2020
1 parent d21326f commit 5faccae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
My Profile
</nuxt-link>
<hr class="navbar-divider">
<a class="navbar-item">Logout</a>
<a class="navbar-item" @click="logout">Logout</a>
</div>
</div>
<template v-else>
Expand All @@ -45,6 +45,15 @@ import { mapGetters } from 'vuex'
export default {
computed: {
...mapGetters(['isAuthenticated', 'loggedInUser'])
},
methods: {
async logout () {
// We call the logout() of the Auth module.
// This will simply delete the user’s token from localstorage
// and redirect the user to the homepage.
await this.$auth.logout()
}
}
}
</script>

0 comments on commit 5faccae

Please sign in to comment.