Better menu ordering ?
[vchess.git] / client / src / views / Logout.vue
CommitLineData
a3ac374b
BA
1<template lang="pug">
2main
3 .row
4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
5 p(:class="{warn:!!this.errmsg}")
6 | {{ errmsg || st.tr["Logout successful!"] }}
7</template>
8
9<script>
10import { store } from "@/store";
11import { ajax } from "@/utils/ajax";
a3ac374b
BA
12export default {
13 name: 'my-logout',
14 data: function() {
15 return {
16 st: store.state,
17 errmsg: "",
18 };
19 },
20 created: function() {
21 // NOTE: this local cleaning would logically happen when we're sure
22 // that token is erased. But in the case a user clear the cookies,
23 // it would lead to situations where he cannot ("locally") log out.
24 // At worst, if token deletion fails the user can erase cookie manually.
25 this.st.user.id = 0;
26 this.st.user.name = "";
27 this.st.user.email = "";
28 this.st.user.notify = false;
29 localStorage.removeItem("myid");
30 localStorage.removeItem("myname");
31 ajax("/logout", "GET"); //TODO: listen for errors?
32 },
33};
34</script>
35
36<style lang="sass" scoped>
37.warn
38 padding: 3px
39 color: red
40 background-color: lightgrey
41 font-weight: bold
42</style>