Class: Ooor::CommonService

Inherits:
Service
  • Object
show all
Defined in:
lib/ooor/services.rb

Instance Method Summary collapse

Methods inherited from Service

define_service, #initialize

Constructor Details

This class inherits a constructor from Ooor::Service

Instance Method Details

#csrf_tokenObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ooor/services.rb', line 39

def csrf_token()
  unless defined?(Nokogiri)
    raise "You need to install the nokogiri gem for this feature"
  end
  require 'nokogiri'
  @session.logger.debug "OOOR csrf_token"
  conn = @session.get_client(:json, "#{@session.base_jsonrpc2_url}")
	 = conn.get('/web/login') do |req|
    req.headers['Cookie'] = "session_id=#{@session.web_session[:session_id]}"
  end.body # TODO implement some caching
  Nokogiri::HTML().css("input[name='csrf_token']")[0]['value']
end