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

Even't function won't fire #138

Closed
dovtenenboim opened this issue Sep 7, 2016 · 6 comments
Closed

Even't function won't fire #138

dovtenenboim opened this issue Sep 7, 2016 · 6 comments

Comments

@dovtenenboim
Copy link

I'm trying to use this plugin as my auth interceptor but for some reason it's not firing. I've used it in previous projects and have had no issues with the same implementation.

In my app.js on run:

    .run(function ($q, $http, $rootScope, $location, $window, $timeout, $state, Auth, authService) {

        $rootScope.$on('event:auth-loginRequired', function () {
          console.log('auth-loginRequired'); //doesn't fire the function so this isn't displayed
          Auth.getNewAccessToken().then(function () {
            authService.loginConfirmed();
          }, function () {
            authService.loginCancelled();
            $state.go('login');
          });
        });

    }

Any idea why it won't fire? No console errors, nothing. I've included the plugins JS file, added it to apps modules etc. but having no luck.

@dovtenenboim
Copy link
Author

Debugging, line 56 of http-auth-interceptor.js, the value of rejection.status is -1 and it doesn't fall in to the 401 case.

@thaume
Copy link

thaume commented Oct 16, 2016

@dovtenenboim it seems like a Chrome bug doesn't it ? I did a hotfix on my local lib, but that sucks. Are you going to open a PR ?

@minasvisual
Copy link

hi, i have the same problem. my rejection.status returned -1 for 401 code. how you guys fix then?

@thaume
Copy link

thaume commented Nov 16, 2016

Right now I modified the library code to respond to -1 status code. Add a case in the switch over here : https://github.com/witoldsz/angular-http-auth/blob/master/src/http-auth-interceptor.js#L57

I can't think of a clean way to handle this thing.

@witoldsz
Copy link
Owner

The solution to this problem could be to introduce an AuthServiceProvider, so the authService could be configurable… The question is how to make it configurable "just enough" :-)

@minasvisual
Copy link

Mannn, i fix then!! use the angular version required by ng-resource, angular-http-auth but and simulate in device or ripple. work for me!

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

4 participants