7d682a0edb898000177d0ddb4febbc6a5c380d2c
[vchess.git] / client / src / views / Auth.vue
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="authOk")
6 p {{ st.tr["Authentication successful!"] }}
7 p {{ st.tr["Back to Hall in 3 seconds..."] }}
8 </template>
9
10 <script>
11 import { store } from "@/store";
12 import { ajax } from "@/utils/ajax";
13 export default {
14 name: "my-auth",
15 data: function() {
16 return {
17 st: store.state,
18 authOk: false
19 };
20 },
21 created: function() {
22 ajax(
23 "/authenticate",
24 "GET",
25 { token: this.$route.params["token"] },
26 res => {
27 this.authOk = true;
28 this.st.user.id = res.id;
29 this.st.user.name = res.name;
30 this.st.user.email = res.email;
31 this.st.user.notify = res.notify;
32 localStorage["myname"] = res.name;
33 localStorage["myid"] = res.id;
34 setTimeout(() => {
35 this.$router.replace("/");
36 }, 3000);
37 }
38 );
39 }
40 };
41 </script>