2018-08-17 06:29:58 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div v-if="$store.state.auth">
|
|
|
|
<p>You are authenticated. You can see the
|
|
|
|
<nuxt-link to="/secret">secret page</nuxt-link>!
|
|
|
|
</p>
|
|
|
|
<button @click="logout">Logout</button>
|
|
|
|
</div>
|
|
|
|
<p v-else>Please
|
|
|
|
<nuxt-link to="/login">login</nuxt-link>.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-19 09:00:23 +00:00
|
|
|
const Cookie = process.client ? require('js-cookie') : undefined
|
2018-08-17 06:29:58 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
logout() {
|
|
|
|
Cookie.remove('auth')
|
|
|
|
this.$store.commit('setAuth', null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|