devise icon indicating copy to clipboard operation
devise copied to clipboard

InvalidAuthenticityToken

Open shenoudab opened this issue 16 years ago • 37 comments

Dears,

i got the below when trying devise from master :

ActionController::InvalidAuthenticityToken in Devise/registrationsController#create

ActionController::InvalidAuthenticityToken

shenoudab avatar Jun 25 '10 13:06 shenoudab

Just started getting the same error myself.

frankjmattia avatar Jun 25 '10 14:06 frankjmattia

Me, too.

Running Rails3 and Devise on edge. There is something wrong with this commit: http://github.com/rails/rails/commit/21c99e93883c1cf32474ad65a507e69e373a380c

russbuelt avatar Jun 25 '10 14:06 russbuelt

Hey guys, is this really a Devise issue? Have you tried in a blank application with scaffold?

josevalim avatar Jun 25 '10 15:06 josevalim

Jose, yes i just setup a blank application. Very wired.

Started POST "/users" for 127.0.0.1 at 2010-06-25 17:02:01 +0200 Processing by Devise::RegistrationsController#create as HTML Parameters: {"authenticity_token"=>"QuJe1iCs/BJbSyRHlOh+v5tANLY2aa+RqImbKN9ch6A=", "user"=>{"first_name"=>"Test", "last_name"=>"Test", "email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"} Completed in 1ms

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

russbuelt avatar Jun 25 '10 15:06 russbuelt

Could you please vendor rails and revert that commit, to confirm it is really the culprit?

josevalim avatar Jun 25 '10 15:06 josevalim

I am seeing the same behaviour and after tagging the previous ref (in Rails HEAD) everything worked again.

I also started getting weird behaviour with multiple scopes. For example, I have an Admin and a User scope, which can sometimes access the same action. To allow that, I created a custom filter called authenticate_anyone!:

def authenticate_anyone!
  if admin_signed_in?
     authenticate_admin!
  else
     authenticate_user!
  end
end

This worked before that commit -- but now it skips straight to user authentication, and my poor admin can't access the actions and is redirected to the user sign in page.

Oddly, though, my tests using sign_in @admin still pass.

nragaz avatar Jun 25 '10 15:06 nragaz

Jep, i can confirm the mentioned commit breaks it.

russbuelt avatar Jun 25 '10 15:06 russbuelt

I cannot reproduce. Which browsers are you using?

josevalim avatar Jun 25 '10 16:06 josevalim

Safari 5

frankjmattia avatar Jun 25 '10 16:06 frankjmattia

Safari 5, Chrome 5 - both Mac OS X 10.6.4

nragaz avatar Jun 25 '10 16:06 nragaz

I cannot duplicate in both browser. Can someone please post a sample application on Github with steps to reproduce?

josevalim avatar Jun 25 '10 16:06 josevalim

Which session store are you using? Cookie? ActiveRecord?

josevalim avatar Jun 25 '10 16:06 josevalim

Cookie.

Sorry, I don't have time to make a sample app right at the moment - later today I will if the issue is still unresolved.

nragaz avatar Jun 25 '10 16:06 nragaz

http://github.com/frankjmattia/Devise_348

frankjmattia avatar Jun 25 '10 16:06 frankjmattia

Oh, my apologies. The readme includes the devise user I "created" but I completely forgot that you'll have to recreate the database anyway... ignore that part.

frankjmattia avatar Jun 25 '10 16:06 frankjmattia

Thanks Frank. Another question, are you using localhost:3000 as host?

josevalim avatar Jun 25 '10 16:06 josevalim

Fixed. Please update your Rails forks! :D

josevalim avatar Jun 25 '10 17:06 josevalim

Yessir. Should I declare it a different way or in a different place?

frankjmattia avatar Jun 25 '10 17:06 frankjmattia

Using Rails master with last Valim's commit is working now.

carlosantoniodasilva avatar Jun 25 '10 17:06 carlosantoniodasilva

Jose, thanks for responding that fast =)

russbuelt avatar Jun 25 '10 19:06 russbuelt