2019-02-22 19:23:42 +00:00
|
|
|
<template>
|
2019-05-27 10:10:50 +00:00
|
|
|
<v-content>
|
|
|
|
|
<v-container>
|
|
|
|
|
<Header>
|
|
|
|
|
<v-btn flat @click.native="logout">Logout</v-btn>
|
|
|
|
|
</Header>
|
2019-05-08 19:34:50 +00:00
|
|
|
|
2019-05-27 10:10:50 +00:00
|
|
|
<template v-if="user">
|
|
|
|
|
<p>user logged in: {{ user.login }}</p>
|
2019-05-14 14:20:38 +00:00
|
|
|
|
2019-05-27 10:10:50 +00:00
|
|
|
<DeckList />
|
|
|
|
|
</template>
|
|
|
|
|
</v-container>
|
|
|
|
|
</v-content>
|
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-05-14 15:59:36 +00:00
|
|
|
import DeckList from '@/components/DeckList.vue'
|
2019-05-08 19:34:50 +00:00
|
|
|
|
2019-02-23 01:40:15 +00:00
|
|
|
export default {
|
2019-05-09 12:20:03 +00:00
|
|
|
name: 'UserCP',
|
2019-05-07 16:09:45 +00:00
|
|
|
|
2019-05-08 19:34:50 +00:00
|
|
|
components: {
|
2019-05-14 15:59:36 +00:00
|
|
|
Header,
|
|
|
|
|
DeckList
|
2019-05-08 19:34:50 +00:00
|
|
|
},
|
|
|
|
|
|
2019-05-27 10:10:50 +00:00
|
|
|
data: () => ({}),
|
|
|
|
|
|
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', {
|
2019-05-20 15:06:40 +00:00
|
|
|
session: this.session
|
2019-05-07 20:15:18 +00:00
|
|
|
})
|
|
|
|
|
.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-14 14:20:38 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
2019-05-14 15:59:36 +00:00
|
|
|
session: () => Cookies.get('session')
|
2019-05-14 14:20:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
asyncComputed: {
|
|
|
|
|
user() {
|
|
|
|
|
return axios
|
|
|
|
|
.post('/user/info', {
|
|
|
|
|
session: this.session
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
if (response.data.success) {
|
|
|
|
|
return response.data.user
|
|
|
|
|
} else {
|
|
|
|
|
this.goHome()
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-02-23 01:40:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|