Permalink
Browse files

fix: no token exception when tokenRequired is set to false (#118)

  • Loading branch information...
RodrigoLeiteF authored and pi0 committed Apr 3, 2018
1 parent 77161b8 commit 56265a70b27bfc35bd54c307ddd89f91504486da
Showing with 2 additions and 6 deletions.
  1. +2 −6 lib/auth/auth.js
@@ -1,7 +1,7 @@
import getProp from 'dotprop'
import Storage from './storage'
import { routeOption, isRelativeURL, isUnset, isSameURL } from './utilities'
import { routeOption, isRelativeURL, isSet, isSameURL } from './utilities'
export default class Auth {
constructor (ctx, options) {
@@ -237,17 +237,13 @@ export default class Auth {
requestWith (strategy, endpoint, defaults) {
const token = this.getToken(strategy)
if (isUnset(token)) {
return Promise.reject(new Error('No Token'))
}
const _endpoint = Object.assign({}, defaults, endpoint)
if (!_endpoint.headers) {
_endpoint.headers = {}
}
if (!_endpoint.headers['Authorization']) {
if (!_endpoint.headers['Authorization'] && isSet(token)) {
_endpoint.headers['Authorization'] = token
}

0 comments on commit 56265a7

Please sign in to comment.