Devise / Rails 4 Windows mobile authentication failure
- by Nic Willemse
Im using devise with a rails 4 application.
Authentication works fine on most devices, including some old feature phones.
I am however running into problems with the Nokia Lumia.
Please see log snippet below. By the looks of things this appears to be a rails issue rather than a devise problem.
Please Help!
014-05-30T09:47:38.668478+00:00 app[web.1]: Started POST "/users/sign_in" for 197.111.223.249 at 2014-05-30 09:47:38 +0000
2014-05-30T09:47:38.668505+00:00 app[web.1]: Started POST "/users/sign_in" for 197.111.223.249 at 2014-05-30 09:47:38 +0000
2014-05-30T09:47:38.672961+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-05-30T09:47:38.672968+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-05-30T09:47:38.674163+00:00 app[web.1]: Can't verify CSRF token authenticity
2014-05-30T09:47:38.673021+00:00 app[web.1]: Parameters: {"utf8"="?", "authenticity_token"="Ckyw9vAfxbgksugLMainfWoG2jRdq7GB5xBBGxqYhCs=", "user"={"email"="", "password"="[FILTERED]", "remember_me"="0"}, "commit"="Sign in"}
2014-05-30T09:47:38.673027+00:00 app[web.1]: Parameters: {"utf8"="?", "authenticity_token"="Ckyw9vAfxbgksugLMainfWoG2jRdq7GB5xBBGxqYhCs=", "user"={"email"="", "password"="[FILTERED]", "remember_me"="0"}, "commit"="Sign in"}
2014-05-30T09:47:38.674170+00:00 app[web.1]: Can't verify CSRF token authenticity
2014-05-30T09:47:38.677792+00:00 app[web.1]: Completed 422 Unprocessable Entity in 5ms
2014-05-30T09:47:38.677799+00:00 app[web.1]: Completed 422 Unprocessable Entity in 5ms
2014-05-30T09:47:38.683294+00:00 app[web.1]: ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
2014-05-30T09:47:38.683299+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.1/lib/action_controller/metal/request_forgery_protection.rb:170:in handle_unverified_request'
2014-05-30T09:47:38.683289+00:00 app[web.1]:
2014-05-30T09:47:38.683298+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.1/lib/action_controller/metal/request_forgery_protection.rb:163:inhandle_unverified_request'
2014-05-30T09:47:38.683303+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.1/lib/action_controller/metal/request_forgery_protection.rb:177:in verify_authenticity_token'
2014-05-30T09:47:38.683305+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:417:in_run__3672081613755604432__process_action__callbacks'
Form :
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => "form-signin"}) do |f| %>
<h2 class="form-signin-heading">Sign in</h2>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true, :class=> "form-control" %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password , :class=> "form-control"%></div>
<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me, :class=> "form-control"%> <%= f.label :remember_me %></div>
<% end -%>
<div><%= f.submit "Sign in" ,:class => "btn btn-lg btn-primary btn-block"%></div>
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>"/>
<%= render "devise/shared/links" %>
<% end %>