Sha256: 3b3dde53b3c31a0c49697948163f99026c1613c2a21e51d1bed34f2ede02cd4e
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# When you do file uploads from Flash with File.upload() that, unfortunately generates a new session id, # which will fail to authenticate if you are using restful-authentication plugin or equivalent. # # The following code is a work-around for the Flash bug that prevents file uploader # from sending correct session_id. Here, we hack the Session#initialize method and force the session_id # to load from the query string via the request URI. # # Based on the code from http://seventytwo.co.uk/posts/making-swfupload-and-rails-work-together # class CGI::Session alias original_initialize initialize def initialize(request, option = {}) option = scan_for_session_id(request, '_session_id', option) unless option['session_id'] original_initialize(request, option) end def scan_for_session_id(request, session_key = '_session_id', option = {}) query_string = if (qs = request.env_table["QUERY_STRING"]) and qs != "" qs elsif (ru = request.env_table["REQUEST_URI"][0..-1]).include?("?") ru[(ru.index("?") + 1)..-1] end if query_string and query_string.include?(session_key) option['session_id'] = query_string.scan(/#{session_key}=(.*?)(&.*?)*$/).flatten.first end return option end end # If you have configured your Rails/Flex/AIR application to share authenticity_token # comment this out to enable forgery protection. By default, this is disabled to allow # generated code to work out of the box. ActionController::Base.allow_forgery_protection = false <% if distributed -%> # If we are in distributed mode we need to make sure that the RestfulX::UUIDHelper is loaded require "restfulx/uuid_helper" <% end -%>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dima-restfulx-1.2.2 | rails_generators/rx_config/templates/restfulx.erb |