Skip to content

Commit

Permalink
fix(core): Remove duplicate angular interceptor
Browse files Browse the repository at this point in the history
Remove the interceptor defined in the users module
Update the interceptor defined in the core module
Update the respective test

Fixes #1096
  • Loading branch information
pgrodrigues committed Dec 16, 2015
1 parent b51e645 commit 996976a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use strict';

angular.module('core').factory('authInterceptor', ['$q', '$injector',
function ($q, $injector) {
angular.module('core').factory('authInterceptor', ['$q', '$injector', 'Authentication',
function ($q, $injector, Authentication) {
return {
responseError: function(rejection) {
if (!rejection.config.ignoreAuthModule) {
switch (rejection.status) {
case 401:
// Deauthenticate the global user
Authentication.user = null;
$injector.get('$state').transitionTo('authentication.signin');
break;
case 403:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var authInterceptor,
$q,
$state,
Authentication,
httpProvider;

// Load the main application module
Expand All @@ -16,10 +17,11 @@
httpProvider = $httpProvider;
}));

beforeEach(inject(function(_authInterceptor_, _$q_, _$state_) {
beforeEach(inject(function(_authInterceptor_, _$q_, _$state_, _Authentication_) {
authInterceptor = _authInterceptor_;
$q = _$q_;
$state = _$state_;
Authentication = _Authentication_;
spyOn($q,'reject');
spyOn($state,'transitionTo');
}));
Expand Down Expand Up @@ -56,6 +58,7 @@
};
var promise = authInterceptor.responseError(response);
expect($q.reject).toHaveBeenCalled();
expect(Authentication.user).toBe(null);
expect($state.transitionTo).toHaveBeenCalledWith('authentication.signin');
});
});
Expand Down
30 changes: 0 additions & 30 deletions modules/users/client/config/users.client.config.js

This file was deleted.

0 comments on commit 996976a

Please sign in to comment.