Fix cookie paths

This commit is contained in:
Henrique Dias
2017-07-20 19:00:51 +01:00
parent 915eb68954
commit 2936858adb
5 changed files with 13 additions and 2392 deletions

View File

@@ -3,7 +3,9 @@ import store from '@/store'
import router from '@/router'
function parseToken (token) {
document.cookie = `auth=${token}; max-age=86400; path=${store.state.baseURL}`
let path = store.state.baseURL
if (path === '') path = '/'
document.cookie = `auth=${token}; max-age=86400; path=${path}`
let res = token.split('.')
let user = JSON.parse(window.atob(res[1]))
store.commit('setJWT', token)
@@ -49,7 +51,9 @@ function login (user, password) {
}
function logout () {
document.cookie = `auth='nothing'; max-age=0; path=${store.state.baseURL}`
let path = store.state.baseURL
if (path === '') path = '/'
document.cookie = `auth='nothing'; max-age=0; path=${path}`
router.push({path: '/login'})
}