This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/frontend/src/views/About.vue

61 lines
1 KiB
Vue
Raw Normal View History

2019-02-22 19:23:42 +00:00
<template>
2019-05-07 16:09:45 +00:00
<v-container>
2019-05-08 19:34:50 +00:00
<Header />
2019-05-07 16:09:45 +00:00
<p>user session: {{ sessionID }}</p>
2019-05-07 20:15:18 +00:00
<v-btn @click.native="logout">Logout</v-btn>
2019-05-07 16:09:45 +00:00
</v-container>
2019-02-22 19:23:42 +00:00
</template>
2019-02-23 01:40:15 +00:00
<script>
2019-05-07 16:09:45 +00:00
import * as Cookies from 'js-cookie'
import axios from '@/plugins/axios'
2019-05-08 19:34:50 +00:00
import Header from '@/components/Header.vue'
2019-02-23 01:40:15 +00:00
export default {
name: 'About',
2019-05-07 16:09:45 +00:00
2019-05-08 19:34:50 +00:00
components: {
Header
},
2019-05-07 16:09:45 +00:00
data: () => ({
sessionID: ''
}),
2019-05-07 20:15:18 +00:00
methods: {
2019-05-07 20:28:51 +00:00
goHome() {
Cookies.remove('session')
this.$router.push({ name: 'home' })
},
2019-05-07 20:15:18 +00:00
logout() {
axios
.post('/user/logout', {
session: Cookies.get('session')
})
.then(response => {
if (response.data.success) {
2019-05-07 20:28:51 +00:00
this.goHome()
2019-05-07 20:15:18 +00:00
}
})
}
},
2019-05-07 16:09:45 +00:00
mounted() {
axios
.post('/user/login', {
session: Cookies.get('session')
})
.then(response => {
2019-05-07 20:28:51 +00:00
if (response.data.success) {
this.sessionID = response.data.message
} else {
this.goHome()
}
2019-05-07 16:09:45 +00:00
})
2019-02-23 01:40:15 +00:00
}
}
</script>