lib/gatleon/rails/authform/concern.rb in gatleon-rails-0.1.9 vs lib/gatleon/rails/authform/concern.rb in gatleon-rails-0.1.10
- old
+ new
@@ -25,20 +25,23 @@
end
define_method :_exchange_user_voucher_for_user do
if params[:_authformForm] == form_uid && params[:_authformUserVoucher]
# TODO: headers for api verification
- response = Faraday.get("#{_authform_base_url}/v1/exchangeUserVoucherForUser/#{params[:_authformUserVoucher]}")
+
+ uri = URI("#{_authform_base_url}/v1/exchangeUserVoucherForUser/#{params[:_authformUserVoucher]}")
+ response = Net::HTTP.get_response(uri)
- if response.status == 200
+ if response.code.to_i == 200
cookies[_authform_user_cookie_key] = {
value: response.body,
domain: :all
}
end
q = Rack::Utils.parse_query(URI.parse(request.url).query)
q.delete("_authformUserVoucher")
+ q.delete("_authformForm")
url = q.empty? ? request.path : "#{request.path}?#{q.to_query}"
redirect_to url, status: 302 # redirect to finish removal of query param
end
end