Re: authenticity_token sent, still InvalidAuthenticityToken

Anjan Tek
2008-10-15T10:53:13Z

Hi!

I think both of you have hit the nail on the head.

Just to avoid confusion, I placed all 3 of my methods in question into
the same controller (one working method, one method that does not work
and one method which renders the page that has the flex app in it).

Here is the log output when I load the rails app in my browser: (I''ve
set map.root to execute the "index" method.
__________________________________________

Processing QuestionsController#index (for 192.170.50.67 at 2008-10-15
15:56:47) [GET]
  Session ID: 594b5d72d93b07f9d6a272f301a3e0f7
  Parameters: {"action"=>"index",
"controller"=>"questions"}
Rendering questions/index
Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00042 (22%) | DB:
0.00000 (0%) | 200 OK [http://192.170.50.67/]


Processing QuestionsController#index (for 192.170.50.67 at 2008-10-15
15:56:47) [GET]
  Session ID:
BAh7BzoMY3NyZl9pZCIlOTdiYWM0MDM0OGM0NmRmZDkzZWJiMDhhNzIwYjIy
ODQiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh
c2h7AAY6CkB1c2VkewA=--1a32065d2fd99849429fc9dec4dcb26ec4e3623a
  Parameters: {"action"=>"index",
"controller"=>"questions",
"debug"=>"true"}
Rendering questions/index
Completed in 0.00193 (517 reqs/sec) | Rendering: 0.00045 (23%) | DB:
0.00000 (0%) | 200 OK [http://192.170.50.67/?debug=true]

________________________________________

I''ve got no idea why it executes the same method twice, but it looks
like the second Session ID is what sticks.

Here is the log output when I call the "insert" method that works:

__________________________________________

Processing QuestionsController#insert (for 192.170.50.67 at 2008-10-15
15:58:24) [POST]
  Session ID:
BAh7BzoMY3NyZl9pZCIlOTdiYWM0MDM0OGM0NmRmZDkzZWJiMDhhNzIwYjIy
ODQiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh
c2h7AAY6CkB1c2VkewA=--1a32065d2fd99849429fc9dec4dcb26ec4e3623a
  Parameters:
{"authenticity_token"=>"86b74406048a7f629bd560eab8de771a74c620be",
"temp_Image_Location"=>"/images/temp",
"images_To_Be_Published"=>"",
"action"=>"insert",
"uuid"=>"927EE8CA-C86B-DDEC-C444-000C98986267",
"separator"=>"&&",
"controller"=>"questions"}
Completed in 0.00565 (176 reqs/sec) | Rendering: 0.00018 (3%) | DB:
0.00000 (0%) | 200 OK [http://192.170.50.67/questions/insert]

__________________________________________

Notice that the Session ID is the same as the "index" method call.


Here is the log output when I call the "upload_image" method that DOES
NOT WORK:

__________________________________________


Processing QuestionsController#upload_image (for 192.170.50.67 at
2008-10-15 15:57:33) [POST]
  Session ID: 8e7a7ad93525bce8a253542d8812ea4a
  Parameters: {"Filename"=>"Spiked.gif",
"temp_Image_Location"=>"/images/temp",
"authenticity_token"=>"86b74406048a7f629bd560eab8de771a74c620be",
"action"=>"upload_image",
"Upload"=>"Submit Query",
"controller"=>"questions",
"random_File_Name"=>"1224066450419_711.gif",
"Filedata"=>#<ActionController::UploadedStringIO:0x26d8600>}


ActionController::InvalidAuthenticityToken
(ActionController::InvalidAuthenticityToken):

__________________________________________

As both of you suspected, the Session ID is different just for this
method call.
And hence the authenticity token that I send is invalid.

If I call the "insert" method again after the "upload_image"
method has
failed, the Session ID is correct again and it works.

But I don''t understand why the Session ID is suddenly different for one
particular method.

Any ideas?

Thanks for the help so far.