Store_Vuex init...
This commit is contained in:
parent
057c089b94
commit
752af19d16
@ -15,6 +15,7 @@ const destroyToken = (key) => {
|
||||
// return jsonwebtoken.decode(getToken(key))
|
||||
// }
|
||||
const isAuthenticated = () => {
|
||||
console.log('isAuthenticated' + getToken())
|
||||
return !!getToken()
|
||||
}
|
||||
const getAuthorizationHeader = (config) => {
|
||||
|
||||
@ -63,7 +63,7 @@ router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some((route) => route.meta.requiredAuth)) {
|
||||
//2. 로그인 인증 않된 경우
|
||||
//console.log(store.getters)
|
||||
//console.log(store.getters['AuthStore/isAuthenticated'])
|
||||
console.log('Router 인증확인:' + store.getters['AuthStore/isAuthenticated'])
|
||||
if (!store.getters['AuthStore/isAuthenticated']) {
|
||||
console.log(from.name + ' => 3. To[' + to.name + '] => 로그인')
|
||||
next({ name: 'login', params: { return_url: to.name } })
|
||||
|
||||
@ -38,13 +38,11 @@ const getters = {
|
||||
const mutations = {
|
||||
login: function (state, payload = {}) {
|
||||
state.tokens = payload.tokens
|
||||
state.isAuthenticated = true
|
||||
jwt.saveToken('acccess_token', payload.tokens.access_token)
|
||||
jwt.saveToken('access_token', payload.tokens.access_token)
|
||||
jwt.saveToken('refresh_token', payload.tokens.refresh_token)
|
||||
},
|
||||
logout: function (state) {
|
||||
state.tokens = {}
|
||||
state.isAuthenticated = false
|
||||
jwt.destroyToken()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user