/**
 * Date: 1/9/15
 * Author: Shirish Goyal
 */

(function () {
  'use strict';

angular
    .module('crowdsource.interceptor', [])
    .factory('AuthHttpResponseInterceptor', AuthHttpResponseInterceptor);

AuthHttpResponseInterceptor.$inject = ['$location', '$log', '$injector', '$q'];

function AuthHttpResponseInterceptor($location, $log, $injector, $q) {
        return {
            responseError: function (rejection) {
                if (rejection.status === 403) {

                    if (rejection.hasOwnProperty('data')
                        && rejection.data.hasOwnProperty('detail')
                        && (rejection.data.detail.indexOf("Authentication credentials were not provided") != -1)
                        ) {
                        var $http = $injector.get('$http');
                        var Authentication = $injector.get('Authentication');

                          if (!Authentication.isAuthenticated()) {
                            $location.path('/login');
                          }else{
                              deferred.resolve(data);
                          }
                    }
                }

                return $q.reject(rejection);
            }
        }
    }

})();
/**
 * Date: 1/9/15
 * Author: Shirish Goyal
 */

(function () {
  'use strict';

angular
    .module('crowdsource.interceptor', [])
    .factory('AuthHttpResponseInterceptor', AuthHttpResponseInterceptor);

AuthHttpResponseInterceptor.$inject = ['$location', '$log', '$injector', '$q'];

function AuthHttpResponseInterceptor($location, $log, $injector, $q) {
        return {
            responseError: function (rejection) {
                if (rejection.status === 403) {

                    if (rejection.hasOwnProperty('data')
                        && rejection.data.hasOwnProperty('detail')
                        && (rejection.data.detail.indexOf("Authentication credentials were not provided") != -1)
                        ) {
                        var $http = $injector.get('$http');
                        var Authentication = $injector.get('Authentication');

                          if (!Authentication.isAuthenticated()) {
                            $location.path('/login');
                          }
                    }
                }

                return $q.reject(rejection);
            }
        }
    }

})();
Remove deferred as not needed
Remove deferred as not needed
