Started code review + some fixes (unfinished)
[vchess.git] / client / src / views / Auth.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["Authentication successful!"] }}
7</template>
8
9<script>
10import { store } from "@/store";
11import { ajax } from "@/utils/ajax";
a3ac374b 12export default {
6808d7a1 13 name: "my-auth",
a3ac374b
BA
14 data: function() {
15 return {
16 st: store.state,
6808d7a1 17 errmsg: ""
a3ac374b
BA
18 };
19 },
20 created: function() {
6808d7a1
BA
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 }
a3ac374b 36 );
6808d7a1 37 }
a3ac374b
BA
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>