Experimental improved behavior of login/logout/multitabs
[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";
12
13export default {
14 name: 'my-logout',
15 data: function() {
16 return {
17 st: store.state,
18 errmsg: "",
19 };
20 },
21 created: function() {
22 // NOTE: this local cleaning would logically happen when we're sure
23 // that token is erased. But in the case a user clear the cookies,
24 // it would lead to situations where he cannot ("locally") log out.
25 // At worst, if token deletion fails the user can erase cookie manually.
26 this.st.user.id = 0;
27 this.st.user.name = "";
28 this.st.user.email = "";
29 this.st.user.notify = false;
30 localStorage.removeItem("myid");
31 localStorage.removeItem("myname");
32 ajax("/logout", "GET"); //TODO: listen for errors?
33 },
34};
35</script>
36
37<style lang="sass" scoped>
38.warn
39 padding: 3px
40 color: red
41 background-color: lightgrey
42 font-weight: bold
43</style>