X-Git-Url: https://git.auder.net/images/pieces/current/gitweb.js?a=blobdiff_plain;f=client%2Fsrc%2Frouter.js;h=0f0384976481dfcbe590c547e1ac0b077e304622;hb=deca03e8aeb7cac9c19b0d43b4642b27299695b5;hp=82f01009542d42f4d69a8844d5835473a96ad3a4;hpb=cf2343cee5729c011770ace6d5b4f79d1ac3a2b6;p=vchess.git diff --git a/client/src/router.js b/client/src/router.js index 82f01009..0f038497 100644 --- a/client/src/router.js +++ b/client/src/router.js @@ -8,6 +8,9 @@ function loadView(view) { return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`) } +import { ajax } from "@/utils/ajax"; +import { store } from "@/store"; + export default new Router({ routes: [ { @@ -25,6 +28,27 @@ export default new Router({ name: "rules", component: loadView("Rules"), }, + { + path: "/authenticate/:token", + name: "authenticate", + beforeEnter: (to, from, next) => { + ajax( + "/authenticate", + "GET", + {token: to.params["token"]}, + (res) => { + store.state.user.id = res.id; + store.state.user.name = res.name; + store.state.user.email = res.email; + store.state.user.notify = res.notify; + // NOTE: mysid isn't cleared (required for potential game continuation) + next(); + } + ); + }, + component: Hall, + //redirect: "/", //problem: redirection before end of AJAX request + }, // { // path: "/about", // name: "about",