docs: def do_access_control(self):
          """`before_request` handler to check if user should be redirected to
          login page."""
          from abilian.services import get_service
  
          if current_app.testing and current_app.config.get("NO_LOGIN"):
              # Special case for tests
              user = User.query.get(0)
              login_user(user, force=True)
              return
  
          state = self.app_state
          user = unwrap(current_user)
  
          # Another special case for tests
          if current_app.testing and getattr(user, "is_admin", False):
              return
  
          security = get_service("security")
          user_roles = frozenset(security.get_roles(user))
          endpoint = request.endpoint
          blueprint = request.blueprint
  
          access_controllers = []
          access_controllers.extend(state.bp_access_controllers.get(None, []))
  
          if blueprint and blueprint in state.bp_access_controllers:
              access_controllers.extend(state.bp_access_controllers[blueprint])
  
          if endpoint and endpoint in state.endpoint_access_controllers:
              access_controllers.extend(state.endpoint_access_controllers[endpoint])
  
          for access_controller in reversed(access_controllers):
              verdict = access_controller(user=user, roles=user_roles)
              if verdict is None:
                  continue
              elif verdict is True:
                  return
              else:
                  if user.is_anonymous:
                      return self.redirect_to_login()
                  raise Forbidden()
  
          # default policy
          if current_app.config.get("PRIVATE_SITE") and user.is_anonymous:
              return self.redirect_to_login()