1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<template>
<ion-page>
<m6-header />
<ion-content :fullscreen="true">
<div v-if="me">
<p>ID: {{ me.id }}</p>
<p>Name: {{ me.name }}</p>
<p>Email: {{ me.email }}</p>
<p>Is staff: {{ me.is_staff }}</p>
<ion-button @click="makeLogout">Logout</ion-button>
</div>
</ion-content>
<m6-footer />
</ion-page>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { IonPage, IonContent } from "@ionic/vue";
import Header from "@/components/Header.vue";
import Footer from "@/components/Footer.vue";
import { mapGetters, mapActions } from "vuex";
export default defineComponent({
name: "UserInfo",
components: {
IonContent,
IonPage,
"m6-header": Header,
"m6-footer": Footer,
},
computed: {
...mapGetters("auth", ["isLogged", "me"]),
},
created() {
if (!this.isLogged) window.location.href = "/sign";
this.getMe()
.then(() => {
if (!this.isLogged) window.location.href = "/sign";
})
.catch(() => {
window.location.href = "/sign";
});
},
methods: {
makeLogout() {
this.logout();
window.location.href = "/sign";
},
...mapActions("auth", ["getMe", "logout"]),
},
});
</script>
|