lib/gatleon/rails/authform/concern.rb in gatleon-rails-0.1.1 vs lib/gatleon/rails/authform/concern.rb in gatleon-rails-0.1.6

- old
+ new

@@ -1,10 +1,12 @@ module Gatleon module Rails module Authform class Concern < Module - def initialize(form_uid:, current_user_method_name: "current_user") + def initialize(form_uid:, + current_user_method_name: "current_user", + root_url: "https://authform.gatleon.com") super() do extend ActiveSupport::Concern included do helper_method "#{current_user_method_name}".to_sym @@ -23,13 +25,16 @@ end define_method :_exchange_user_voucher_for_user do if params[:_authformForm] == form_uid && params[:_authformUserVoucher] # TODO: headers for api verification - response = Faraday.get("https://authform.gatleon.com/v1/exchangeUserVoucherForUser/#{params[:_authformUserVoucher]}") + response = Faraday.get("#{root_url}/v1/exchangeUserVoucherForUser/#{params[:_authformUserVoucher]}") if response.status == 200 - cookies[_authform_user_cookie_key] = response.body + cookies[_authform_user_cookie_key] = { + value: response.body, + domain: :all + } end q = Rack::Utils.parse_query(URI.parse(request.url).query) q.delete("_authformUserVoucher") url = q.empty? ? request.path : "#{request.path}?#{q.to_query}"