Fixes, improvements
[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
BA
12export 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) //if not already logged in
27 {
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 }
35 else
36 this.errmsg = res.errmsg;
37 }
38 );
39 },
40};
41</script>
42
43<style lang="sass" scoped>
44.warn
45 padding: 3px
46 color: red
47 background-color: lightgrey
48 font-weight: bold
49</style>