Skip to content

Commit

Permalink
Revert "Merge pull request #77 from seegno/enhancement/authorization-…
Browse files Browse the repository at this point in the history
…header"
  • Loading branch information
ruipenso committed Feb 12, 2016
1 parent 219e035 commit 1d60347
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/interceptors/oauth-interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
function oauthInterceptor($q, $rootScope, OAuthToken) {
return {
request: function(config) {
config.headers = config.headers || {};

// Inject `Authorization` header.
if (!config.headers.hasOwnProperty('Authorization') && OAuthToken.getAuthorizationHeader()) {
if (OAuthToken.getAuthorizationHeader()) {
config.headers = config.headers || {};
config.headers.Authorization = OAuthToken.getAuthorizationHeader();
}

Expand Down
22 changes: 0 additions & 22 deletions test/unit/interceptors/oauth-interceptor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,6 @@ describe('oauthInterceptor', function() {
$httpBackend.flush();
}));

it('should not inject `Authorization` header if it already exists', inject(function($http, $httpBackend, OAuthToken) {
OAuthToken.setToken({ token_type: 'bearer', access_token: 'foo', expires_in: 3600, refresh_token: 'bar' });

$httpBackend.expectGET('https://website.com', function(headers) {
headers.Authorization = undefined;

return headers;
}).respond(200);

$http.get('https://website.com').then(function(response) {
response.config.headers.should.have.property('Authorization');
(undefined === response.config.headers.Authorization).should.be.true;
}).catch(function() {
should.fail();
});

$httpBackend.flush();

$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
}));

it('should remove `token` if an `invalid_request` error occurs', inject(function($http, $httpBackend, OAuthToken) {
sinon.spy(OAuthToken, 'removeToken');

Expand Down

0 comments on commit 1d60347

Please sign in to comment.