diff --git a/client/src/components/global/navbar/navbar.vue b/client/src/components/global/navbar/navbar.vue index 20b899c..99f0d9a 100644 --- a/client/src/components/global/navbar/navbar.vue +++ b/client/src/components/global/navbar/navbar.vue @@ -10,10 +10,13 @@ {{ link.text }} - @@ -24,6 +27,7 @@ name: 'navbar', data() { return { + user: this.$cookies.get("U_"), links: [ { text: 'Sortilèges', diff --git a/client/src/main.js b/client/src/main.js index d4de66a..c5f47a7 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -14,6 +14,7 @@ require('dotenv').config() // Cookies import VueCookies from 'vue-cookies' Vue.use(VueCookies) +Vue.$cookies.config('30d','','') // Jquery import jquery from 'jquery' diff --git a/client/src/pages/user/login-page.vue b/client/src/pages/user/login-page.vue index e2db8f0..b201808 100644 --- a/client/src/pages/user/login-page.vue +++ b/client/src/pages/user/login-page.vue @@ -52,8 +52,7 @@ export default { "password": this.password }) .then(v => { - let user = v.data - this.$cookies.set("loggedUser", user, 60 * 60 * 24 * 30) + this.$cookies.set("U_", v.data.user, 60 * 60 * 24 * 30) }) .catch(err => { console.log(err) diff --git a/client/src/pages/user/profile-page.vue b/client/src/pages/user/profile-page.vue index 944eb37..b24c702 100644 --- a/client/src/pages/user/profile-page.vue +++ b/client/src/pages/user/profile-page.vue @@ -1,14 +1,17 @@ diff --git a/client/src/routes.js b/client/src/routes.js index 8ca8eaa..e19646a 100644 --- a/client/src/routes.js +++ b/client/src/routes.js @@ -69,10 +69,10 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.authGuard)) { - if (Vue.$cookies.get('loggedUser') == null) { + if (Vue.$cookies.get('U_') == null) { next({ path: '/connexion', - params: { nextUrl: to.fullPath } + params: { nextUrl: to.fullPath }, }) } else { next() diff --git a/package.json b/package.json index 0e4bf54..f93fffe 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "API for Auracle database", "main": "index.js", "scripts": { - "test": "start" + "api": "node index.js", + "client": "cd client && npm run serve" }, "repository": { "type": "git",