Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <div>
  2. <main-nav></main-nav>
  3. <router-view></router-view>
  4. </div>
  5.  
  6. <template>
  7. <li v-show="loggedIn">
  8. <a @click="logout">Logout</a>
  9. </li>
  10. </template>
  11.  
  12. <script>
  13. import { isLoggedIn, logout } from '@/tools/Auth'
  14.  
  15. export default {
  16. computed: {
  17. loggedIn: {
  18. cache: false,
  19. get() {
  20. return isLoggedIn()
  21. }
  22. }
  23. },
  24.  
  25. methods: {
  26. logout() {
  27. logout().then(() => {
  28. this.$router.push({ name: 'Login' })
  29. // this is necessary or the nav isn't updated after logout
  30. this.$forceUpdate()
  31. })
  32. }
  33. }
  34. }
  35. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement