3 Replies Latest reply on Jul 9, 2013 3:28 AM by Kutir Mobility

    How to use application.rb login session in source adopters

      Hi All,

       

      I have a small query for Rhoconnect.

       

      def authenticate(username,pin,session)

            settings = Rhoconnect.get_config(Rhoconnect.base_directory)

           @login_url = settings[:development][:WebAPIServer] + settings[:login_url]

            puts "login_url:  '#{@login_url}'"

            @username = username

            @pin = pin)

            @node = ""

            user_info = Nokogiri::XML(get_response)

            user_info.search('//error').each do |m|

              @node = m.text

            end

            if( @node == "Invalid login")

              false

            else

              puts "RESPONSE TOKEN IS:  '#{get_response.cookies['PHPSESSID']}'"

               Store.put_data('AppSession',{'1' => get_response.cookies})  - want to use  username instead of 1 or something else that can be use in source adapters.

               puts "RESPONSE TOKEN from redis:  '#{Store.get_data('AppSession')['1']}'"

              return Store.get_data('AppSession')['1']

            end

          end

       

       

      i am using this into source adapters as

       

      puts "inside Department adaptor::query"

           settings = Rhoconnect.get_config(Rhoconnect.base_directory)

           @dept_url = settings[:development][:WebAPIServer] + settings[:department-url]

           department = RestClient::Request.execute(:method => :get, :url => @dept_url , :timeout => 10000, :cookies => Store.get_data('AppSession')["1"])

       

      I am always picking Store.get_data('AppSession')["1"]) for each adapters but i want generic way how can i implement this please help .