Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interceptor automatically captures all 401s and prevents other interceptors from having an opportunity to examine them #145

Open
jeremy-nation opened this issue Jun 6, 2018 · 0 comments

Comments

@jeremy-nation
Copy link

Hello!

First, I'd like to say thanks for creating this project! It's saved me a lot of time and is (almost) perfect for my needs.

In my particular scenario, I'd like to use this interceptor to handle some 401s but not all of them. The ignoreAuthModule config flag works great for scenarios where you know ahead of time that a particular call will produce a 401 that should be ignored.

For our application, a 401 can be returned for different scenarios and we may not know how the 401 should be handled until the response is received. It would be great if the interceptor had the ability to examine the response based on some custom criteria to determine whether or not it should let it pass through or capture it. The code below illustrates this idea (From line 56 in http-auth-interceptor.js)

Original

if (!config.ignoreAuthModule) {
   ...
}
// otherwise, default behaviour
return $q.reject(rejection);

Proposal

if (!config.ignoreAuthModule && passesCustomCriteria(rejection)) {
   ...
}
// otherwise, default behaviour
return $q.reject(rejection);

Using the above logic, the 401 is allowed to propagate to other interceptors and is not captured if it doesn't match the custom criteria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant