Skip to content

Commit

Permalink
fix: no token exception when tokenRequired is set to false (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyLeite authored and pi0 committed Apr 3, 2018
1 parent 77161b8 commit 56265a7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/auth/auth.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 56265a7

Please sign in to comment.