title: Log out if status code is 403 in angularjs
body: <p>I have a SPA(single page application), and it sends a lot of http requests to a server and the server checks whether the user who is sending the request is authenticated or not.</p>
  
  <p>If the user is not authenticated, I redirect him to a login page like this:</p>
  
  <pre><code>$scope.getGroups = function () {
      $http({
          method: "get",
          url: "/enterprises/groups"
      }).success(function (response) {
          GroupService.updateGroups(response.groups);
      }).error(function (errResponse, status) {
          if(status == 403){
              $location.path("login")
          }
      });
  };
  </code></pre>
  
  <p>The problem is that I have a lot of http requests and I don't want to handle the "forbidden" exception every time. </p>
  
  <p>Is there any way to write this kind of code in, let's say, config and apply it everywhere?</p>