Started code review + some fixes (unfinished)
[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 p(:class="{warn:!!this.errmsg}")
6 | {{ errmsg || st.tr["Authentication successful!"] }}
7 </template>
8
9 <script>
10 import { store } from "@/store";
11 import { ajax } from "@/utils/ajax";
12 export default {
13 name: "my-auth",
14 data: function() {
15 return {
16 st: store.state,
17 errmsg: ""
18 };
19 },
20 created: function() {
21 ajax(
22 "/authenticate",
23 "GET",
24 { token: this.$route.params["token"] },
25 res => {
26 if (!res.errmsg) {
27 //if not already logged in
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 } else this.errmsg = res.errmsg;
35 }
36 );
37 }
38 };
39 </script>
40
41 <style lang="sass" scoped>
42 .warn
43 padding: 3px
44 color: red
45 background-color: lightgrey
46 font-weight: bold
47 </style>