2018-08-17 06:29:58 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div v-if="$store.state.auth">
|
2018-11-24 18:49:19 +00:00
|
|
|
<p>
|
|
|
|
You are authenticated. You can see the
|
|
|
|
<NuxtLink to="/secret">
|
|
|
|
secret page
|
|
|
|
</NuxtLink>!
|
2018-08-17 06:29:58 +00:00
|
|
|
</p>
|
2018-11-24 18:49:19 +00:00
|
|
|
<button @click="logout">
|
|
|
|
Logout
|
|
|
|
</button>
|
2018-08-17 06:29:58 +00:00
|
|
|
</div>
|
2018-11-24 18:49:19 +00:00
|
|
|
<p v-else>
|
|
|
|
Please
|
|
|
|
<NuxtLink to="/login">
|
|
|
|
login
|
|
|
|
</NuxtLink>.
|
2018-08-17 06:29:58 +00:00
|
|
|
</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: {
|
2019-07-10 10:45:49 +00:00
|
|
|
logout () {
|
2018-08-17 06:29:58 +00:00
|
|
|
Cookie.remove('auth')
|
|
|
|
this.$store.commit('setAuth', null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|