code: def can_user_access_build(param_name):
      
      build_id = (
          request.args.get(param_name, type=int) or
          request.form.get(param_name, type=int) or
          request.json[param_name])
      if not build_id:
          logging.debug('Build ID in param_name=%r was missing', param_name)
          abort(400)
  
      ops = operations.UserOps(current_user.get_id())
      build, user_is_owner = ops.owns_build(build_id)
      if not build:
          logging.debug('Could not find build_id=%r', build_id)
          abort(404)
  
      if current_user.is_authenticated() and not user_is_owner:
          # Assume the user should be able to access the build but can't because
          # the cache is out of date. This forces the cache to repopulate, any
          # outstanding user invitations to be completed, hopefully resulting in
          # the user having access to the build.
          ops.evict()
          claim_invitations(current_user)
          build, user_is_owner = ops.owns_build(build_id)
  
      if not user_is_owner:
          if current_user.is_authenticated() and current_user.superuser:
              pass
          elif request.method != 'GET':
              logging.debug('No way to log in user via modifying request')
              abort(403)
          elif build.public:
              pass
          elif current_user.is_authenticated():
              logging.debug('User does not have access to this build')
              abort(flask.Response('You cannot access this build', 403))
          else:
              logging.debug('Redirecting user to login to get build access')
              abort(login.unauthorized())
      elif not login_fresh():
          logging.debug('User login is old; forcing refresh')
          abort(login.needs_refresh())
  
      return build
docs: Determines if the current user can access the build ID in the request.
  
      Args:
          param_name: Parameter name to use for getting the build ID from the
              request. Will fetch from GET or POST requests.
  
      Returns:
          The build the user has access to.