| 1 | <template lang="pug"> |
| 2 | main |
| 3 | .row |
| 4 | .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 |
| 5 | div(v-if="logoutOk") |
| 6 | p {{ st.tr["Logout successful!"] }} |
| 7 | </template> |
| 8 | |
| 9 | <script> |
| 10 | import { store } from "@/store"; |
| 11 | import { ajax } from "@/utils/ajax"; |
| 12 | export default { |
| 13 | name: "my-logout", |
| 14 | data: function() { |
| 15 | return { |
| 16 | st: store.state, |
| 17 | logoutOk: false |
| 18 | }; |
| 19 | }, |
| 20 | created: function() { |
| 21 | ajax( |
| 22 | "/logout", |
| 23 | "GET", |
| 24 | { |
| 25 | credentials: true, |
| 26 | success: () => { |
| 27 | this.logoutOk = true; |
| 28 | this.st.user.id = 0; |
| 29 | this.st.user.name = ""; |
| 30 | this.st.user.email = ""; |
| 31 | this.st.user.notify = false; |
| 32 | localStorage.removeItem("myid"); |
| 33 | localStorage.removeItem("myname"); |
| 34 | } |
| 35 | } |
| 36 | ); |
| 37 | } |
| 38 | }; |
| 39 | </script> |