Skip to content

Commit 1d60347

Browse files
committed
Revert "Merge pull request #77 from seegno/enhancement/authorization-header"
1 parent 219e035 commit 1d60347

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/interceptors/oauth-interceptor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
function oauthInterceptor($q, $rootScope, OAuthToken) {
77
return {
88
request: function(config) {
9-
config.headers = config.headers || {};
10-
119
// Inject `Authorization` header.
12-
if (!config.headers.hasOwnProperty('Authorization') && OAuthToken.getAuthorizationHeader()) {
10+
if (OAuthToken.getAuthorizationHeader()) {
11+
config.headers = config.headers || {};
1312
config.headers.Authorization = OAuthToken.getAuthorizationHeader();
1413
}
1514

test/unit/interceptors/oauth-interceptor.spec.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,6 @@ describe('oauthInterceptor', function() {
3737
$httpBackend.flush();
3838
}));
3939

40-
it('should not inject `Authorization` header if it already exists', inject(function($http, $httpBackend, OAuthToken) {
41-
OAuthToken.setToken({ token_type: 'bearer', access_token: 'foo', expires_in: 3600, refresh_token: 'bar' });
42-
43-
$httpBackend.expectGET('https://website.com', function(headers) {
44-
headers.Authorization = undefined;
45-
46-
return headers;
47-
}).respond(200);
48-
49-
$http.get('https://website.com').then(function(response) {
50-
response.config.headers.should.have.property('Authorization');
51-
(undefined === response.config.headers.Authorization).should.be.true;
52-
}).catch(function() {
53-
should.fail();
54-
});
55-
56-
$httpBackend.flush();
57-
58-
$httpBackend.verifyNoOutstandingExpectation();
59-
$httpBackend.verifyNoOutstandingRequest();
60-
}));
61-
6240
it('should remove `token` if an `invalid_request` error occurs', inject(function($http, $httpBackend, OAuthToken) {
6341
sinon.spy(OAuthToken, 'removeToken');
6442

0 commit comments

Comments
 (0)