Permalink
Browse files

fix(storage): use false value for unsetting token/user (#160)

  • Loading branch information...
nysos3 authored and pi0 committed Apr 29, 2018
1 parent 42b4061 commit 0450b57d6064b37d38f332cd99bcc13d2d0e713b
Showing with 10 additions and 6 deletions.
  1. +4 −5 lib/core/auth.js
  2. +6 −1 lib/core/storage.js
@@ -150,9 +150,9 @@ export default class Auth {
reset () {
if (!this.strategy.reset) {
this.setUser(null)
this.setToken(this.$state.strategy, null)
this.setRefreshToken(this.$state.strategy, null)
this.setUser(false)
this.setToken(this.$state.strategy, false)
this.setRefreshToken(this.$state.strategy, false)
return Promise.resolve()
}
@@ -270,8 +270,7 @@ export default class Auth {
if (!_endpoint.headers) {
_endpoint.headers = {}
}
if (!_endpoint.headers['Authorization'] && isSet(token)) {
if (!_endpoint.headers['Authorization'] && isSet(token) && token) {
_endpoint.headers['Authorization'] = token
}
@@ -156,6 +156,9 @@ export default class Storage {
const _key = this.options.localStorage.prefix + key
const value = localStorage.getItem(_key)
if (value === 'false') {
return false
}
return isJson ? JSON.parse(value) : value
}
@@ -195,7 +198,9 @@ export default class Storage {
const cookies = parseCookie(cookieStr || '') || {}
const value = cookies[_key]
if (value === 'false') {
return false
}
return isJson ? JSON.parse(value) : value
}
}

0 comments on commit 0450b57

Please sign in to comment.