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

How to skip 401 interception for Auth.currentUser() ? #94

Open
avmuresan opened this issue Mar 16, 2016 · 0 comments
Open

How to skip 401 interception for Auth.currentUser() ? #94

avmuresan opened this issue Mar 16, 2016 · 0 comments

Comments

@avmuresan
Copy link

Auth.currentUser() doesn't accept a config param as Auth.login(user, config) does.
In case it needs to do the login, no config is sent and the 401 Status will be handled by the Interceptor (if set globally).

On my application, I configured the global 401 Interceptor and on some states I call the Auth.currentUser() before loading them :

$stateProvider.state('feed', { url: "/feed", templateUrl: "feed.html", controller: "FeedController", controllerAs: "mainCtrl", resolve: { auth: ['$q', '$state', 'Auth', function($q, $state, Auth) { return Auth.currentUser().then( function(user) {}, function(error) { $state.go('login'); return $q.reject(error); }); }] } });

Now, when the user is not logged in and tries to access that page, an Auth.login() call will be made which will respond with the 401 status and then caught by the interceptor. I need to skip the interception for this call so it can be redirected to login.

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