AngularJS请求拦截器和http身份验证拦截器

AngularJS请求拦截器和http身份验证拦截器,angularjs,angular-http-interceptors,Angularjs,Angular Http Interceptors,如果用户未登录,我会很成功地使用弹出模式。我试图抢占所有请求,即使用户未通过身份验证,也不让其退出。当前,当用户点击应用程序时,它将弹出模式,正如预期的那样,但在成功登录后,重新发送缓冲请求将返回以下错误: TypeError: Cannot read property 'protocol' of undefined at urlIsSameOrigin (http://localhost:9000/bower_components/angular/angular.js:14340:17) at

如果用户未登录,我会很成功地使用弹出模式。我试图抢占所有请求,即使用户未通过身份验证,也不让其退出。当前,当用户点击应用程序时,它将弹出模式,正如预期的那样,但在成功登录后,重新发送缓冲请求将返回以下错误:

TypeError: Cannot read property 'protocol' of undefined
at urlIsSameOrigin (http://localhost:9000/bower_components/angular/angular.js:14340:17)
at sendReq (http://localhost:9000/bower_components/angular/angular.js:8256:25)
at $http.serverRequest (http://localhost:9000/bower_components/angular/angular.js:7995:16)
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11485:81)
at wrappedCallback (http://localhost:9000/bower_components/angular/angular.js:11485:81)
at http://localhost:9000/bower_components/angular/angular.js:11571:26
at Scope.$eval (http://localhost:9000/bower_components/angular/angular.js:12595:28)
at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:12407:31)
at Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:12699:24)
at done (http://localhost:9000/bower_components/angular/angular.js:8287:45) 
代码似乎缓冲了两个模板请求,然后弹出模式。成功通过模式后,sendReq将在两个缓冲请求上运行,并在这些请求返回时运行,这些请求在urlIsSameOrigin中出错。有人有什么建议吗?这是我的模块:

'use strict';

angular.module('app')
  .factory('myAuth', ['$http','mySessionService','authService','$rootScope', function ($http, mySessionService, authService, $rootScope) {
    return {

      /* snip */

    };
  }])
  .config(['$httpProvider', function($httpProvider) {

    function isAuthenticated(mySessionService) {
      var session = mySessionService.getUserProfile();
      if(typeof session !== 'undefined' && !!session.username){
        return true;
      }
      return false
    }

    function isWhiteListed(url){
      switch (url){
        case "views/login.html":
        case "api/auth/":
          return true;
        default:
          return false;
      }
    }

    $httpProvider.interceptors.push(['$rootScope', '$q', 'httpBuffer', 'mySessionService',function($rootScope, $q, httpBuffer,mySessionService) {
      return {
        request: function(config) {
          //if not logged in    and not login form or auth endpoint:
          if(!isAuthenticated(mySessionService) && !isWhiteListed(config.url)){

            var deferred = $q.defer();
            $rootScope.$broadcast('event:auth-loginRequired', config);
            httpBuffer.append(config, deferred);
            return deferred.promise;
          }

          return config || $q.when(config);
        }
      }
    }]);
  }])

你有没有想过?我现在正在和它搏斗