$httpProvider interceptor

.factory('auth403', ['$rootScope', '$q', '$location', function auth403($rootScope, $q, $location) {

      return {
        request: function (config) {
          console.log(config);
          var start = new Date();
          return config;
        },
        response: function (result) {

          return result;
        },
        responseError: function (rejection) {
          console.warn('Failed with http', (rejection.message || rejection.status), 'status');
          if (rejection.status == 403) {
            console.warn('Forbidden, need login to auth');
            $location.path('/login');
          }
          return $q.reject(rejection);
        }
      };
          }])
posted on 2015-06-15 10:02  杨杨0708  阅读(435)  评论(0编辑  收藏  举报