lib/bugzilla/user.rb
def session(user, password)
      key, fname = authentication_method

      # TODO
      # make those variables available
      host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)

      conf = load_authentication_token(fname)

      val = conf.fetch(host, nil)

      if !val.nil?
        if key == :token
          @iface.token = val
        else
          @iface.cookie = val
        end
        yield
      elsif user.nil? || password.nil?
        yield
        return
      else
        login('login' => user, 'password' => password, 'remember' => true)
        yield
      end

      conf[host] = @iface.send(key) if %i[token cookie].include? key

      save_authentication_token(fname, conf)
      key
    end
def session(user, password)
      key, fname = authentication_method

      # TODO
      # make those variables available
      host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)

      conf = load_authentication_token(fname)

      val = conf.fetch(host, nil)

      if !val.nil?
        if key == :token
          @iface.token = val
        else
          @iface.cookie = val
        end
        yield
      elsif user.nil? || password.nil?
        yield
        return
      else
        login('login' => user, 'password' => password, 'remember' => true)
        yield
      end

      conf[host] = @iface.send(key) if %i[token cookie].include? key

      save_authentication_token(fname, conf)
      key
    end
rdoc

 ==== Bugzilla::User#session(user, password)

 Keeps the bugzilla session during doing something in the block.