From 7fa064a48b875f0eee3e98f605dcd8a9e4a2f754 Mon Sep 17 00:00:00 2001 From: Rodrigo Leite Date: Tue, 3 Apr 2018 11:24:01 -0300 Subject: [PATCH 1/3] Fix No Token exception when tokenRequired is set to false --- lib/auth/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth/auth.js b/lib/auth/auth.js index 60d4d26f6..2dd77de34 100644 --- a/lib/auth/auth.js +++ b/lib/auth/auth.js @@ -237,7 +237,7 @@ export default class Auth { requestWith (strategy, endpoint, defaults) { const token = this.getToken(strategy) - if (isUnset(token)) { + if (this.strategy.options.tokenRequired && isUnset(token)) { return Promise.reject(new Error('No Token')) } From ea7060667d63bbd49ac8a82b267ec3bf46cf8be5 Mon Sep 17 00:00:00 2001 From: Rodrigo Leite Date: Tue, 3 Apr 2018 11:48:22 -0300 Subject: [PATCH 2/3] Remove promise rejection as to not make assumptions about the scheme's options --- lib/auth/auth.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/auth/auth.js b/lib/auth/auth.js index 2dd77de34..1bb042933 100644 --- a/lib/auth/auth.js +++ b/lib/auth/auth.js @@ -237,17 +237,13 @@ export default class Auth { requestWith (strategy, endpoint, defaults) { const token = this.getToken(strategy) - if (this.strategy.options.tokenRequired && 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'] && isUnset(token)) { _endpoint.headers['Authorization'] = token } From 5d3a3ff60269a90a45eb7a16944494ba05cee9f1 Mon Sep 17 00:00:00 2001 From: Rodrigo Leite Date: Tue, 3 Apr 2018 11:52:45 -0300 Subject: [PATCH 3/3] Fix wrong function call --- lib/auth/auth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/auth/auth.js b/lib/auth/auth.js index 1bb042933..69fd1c1e9 100644 --- a/lib/auth/auth.js +++ b/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) { @@ -243,7 +243,7 @@ export default class Auth { _endpoint.headers = {} } - if (!_endpoint.headers['Authorization'] && isUnset(token)) { + if (!_endpoint.headers['Authorization'] && isSet(token)) { _endpoint.headers['Authorization'] = token }