Skip to content

Commit fbb34b3

Browse files
author
André Coelho
committed
Fix unsupported headers and status of undefined
1 parent 726252a commit fbb34b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/interceptors/oauth-interceptor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ function oauthInterceptor($q, $rootScope, OAuthToken) {
1616
return config;
1717
},
1818
responseError: function(rejection) {
19+
if (!rejection) {
20+
return $q.reject(rejection);
21+
}
22+
1923
// Catch `invalid_request` and `invalid_grant` errors and ensure that the `token` is removed.
2024
if (400 === rejection.status && rejection.data &&
2125
('invalid_request' === rejection.data.error || 'invalid_grant' === rejection.data.error)
@@ -29,7 +33,7 @@ function oauthInterceptor($q, $rootScope, OAuthToken) {
2933
// The token isn't removed here so it can be refreshed when the `invalid_token` error occurs.
3034
if (401 === rejection.status &&
3135
(rejection.data && 'invalid_token' === rejection.data.error) ||
32-
(rejection.headers('www-authenticate') && 0 === rejection.headers('www-authenticate').indexOf('Bearer'))
36+
(rejection.headers && rejection.headers('www-authenticate') && 0 === rejection.headers('www-authenticate').indexOf('Bearer'))
3337
) {
3438
$rootScope.$emit('oauth:error', rejection);
3539
}

0 commit comments

Comments
 (0)