title: Authorization interceptor with Infinity-scroll in AngularJS
body: <p>I'm using <a href="https://github.com/witoldsz/angular-http-auth" rel="nofollow"><code>angular-http-auth</code></a> for intercepting 401 response in order to display login dialogue and when the user is authorized, to retry failed request. </p>
  
  <p>Since I'm using <code>infinity-scroll</code> I'm increasing an offset value, with every additional upload:</p>
  
  <pre><code>var upload = function () {
                   dataResource.query($scope.model).then(function (result) {
                       angular.forEach(result.items, function (value) {                            
                           $scope.items.push(value);
                       });                        
                   });
               }
  
  $scope.uploadMore = function () {                    
                          $scope.model.Offset = $scope.model.Offset + 10;
                          upload();                                            
                      }; 
  upload();
  </code></pre>
  
  <p>When my page loads up it immediately sends 2 request to server upload(), invoked from this directive, and uploadMore() by <code>infinity-scroll</code>.</p>
  
  <p>However, after user has logged in, <strong>the page does not display the first 10 entries, instead it displays 11-20 items 2 times in a row</strong>. </p>
  
  <p>When I tried to debug it, I noticed that when <code>angular-http-auth</code> retries requests it uses increased by 10 Offset value for both queries(<code>$scope.module</code> argument). </p>
  
  <p>Functions <code>upload()</code> and <code>uploadMore()</code> are running for 2 times before <code>angular-http-auth</code>, so I guess that is why interceptor uses updated argument for both queries.</p>
  
  <p>Could somebody please help me with this problem?</p>