Commit | Line | Data |
---|---|---|
a3ac374b BA |
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 | ||
13 | export default { | |
14 | name: 'my-auth', | |
15 | data: function() { | |
16 | return { | |
17 | st: store.state, | |
18 | errmsg: "", | |
19 | }; | |
20 | }, | |
21 | created: function() { | |
22 | ajax( | |
23 | "/authenticate", | |
24 | "GET", | |
25 | {token: this.$route.params["token"]}, | |
26 | (res) => { | |
27 | if (!res.errmsg) //if not already logged in | |
28 | { | |
29 | this.st.user.id = res.id; | |
30 | this.st.user.name = res.name; | |
31 | this.st.user.email = res.email; | |
32 | this.st.user.notify = res.notify; | |
33 | localStorage["myname"] = res.name; | |
34 | localStorage["myid"] = res.id; | |
35 | } | |
36 | else | |
37 | this.errmsg = res.errmsg; | |
38 | } | |
39 | ); | |
40 | }, | |
41 | }; | |
42 | </script> | |
43 | ||
44 | <style lang="sass" scoped> | |
45 | .warn | |
46 | padding: 3px | |
47 | color: red | |
48 | background-color: lightgrey | |
49 | font-weight: bold | |
50 | </style> |