Devise / Rails 4移动身份验证失败

时间:2014-05-31 07:03:35

标签: ruby-on-rails windows devise nokia lumia

我正在使用带有rails 4应用程序的设计。

身份验证在大多数设备上运行良好,包括一些旧功能手机。

然而,我遇到了诺基亚Lumia和Blackberry Z10的问题

请参阅下面的日志片段。从外观上看,这似乎是一个轨道问题,而不是一个设计问题。

请帮忙!

  

014-05-30T09:47:38.668478 + 00:00 app [web.1]:在2014-05-30 09:47:38 +0000开始发布“/ users / sign_in”的197.111.223.249   2014-05-30T09:47:38.668505 + 00:00 app [web.1]:在2014-05-30 09:47:38 +0000开始发布“/ users / sign_in”的197.111.223.249   2014-05-30T09:47:38.672961 + 00:00 app [web.1]:由Devise处理:: SessionsController #create as HTML   2014-05-30T09:47:38.672968 + 00:00 app [web.1]:由Devise处理:: SessionsController #create as HTML   2014-05-30T09:47:38.674163 + 00:00 app [web.1]:无法验证CSRF令牌真实性   2014-05-30T09:47:38.673021 + 00:00 app [web.1]:参数:{“utf8”=>“✓”,“authenticity_token”=>“Ckyw9vAfxbgksugLMainfWoG2jRdq7GB5xBBGxqYhCs =”,“user”=> {“email”=>“”,“password”=>“[FILTERED]”,“remember_me”=>“0”},“commit”=>“登录”}   2014-05-30T09:47:38.673027 + 00:00 app [web.1]:参数:{“utf8”=>“✓”,“authenticity_token”=>“Ckyw9vAfxbgksugLMainfWoG2jRdq7GB5xBBGxqYhCs =”,“user”=> {“email”=>“”,“password”=>“[FILTERED]”,“remember_me”=>“0”},“commit”=>“登录”}   2014-05-30T09:47:38.674170 + 00:00 app [web.1]:无法验证CSRF令牌真实性   2014-05-30T09:47:38.677792 + 00:00 app [web.1]:在5ms完成422个不可处理的实体   2014-05-30T09:47:38.677799 + 00:00 app [web.1]:在5ms内完成422个不可处理的实体   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:在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:in handle_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:在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_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 %>
浏览器中的

HTML

  <!DOCTYPE html>
<html>
<head>
<script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"beacon-6.newrelic.com","errorBeacon":"bam.nr-data.net","licenseKey":"007e4afc34","applicationID":"3726760","transactionName":"egsMQRdZXAoARBwAUU8NEVBKRVUVFl9cCkcWCgdC","queueTime":9,"applicationTime":8,"ttGuid":"","agentToken":null,"agent":"js-agent.newrelic.com/nr-411.min.js"}</script>
<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(t,n,e){function r(e){if(!n[e]){var o=n[e]={exports:{}};t[e][0].call(o.exports,function(n){var o=t[e][1][n];return r(o?o:n)},o,o.exports)}return n[e].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<e.length;o++)r(e[o]);return r}({D5DuLP:[function(t,n){function e(t,n){var e=r[t];return e?e.apply(this,n):(o[t]||(o[t]=[]),void o[t].push(n))}var r={},o={};n.exports=e,e.queues=o,e.handlers=r},{}],handle:[function(t,n){n.exports=t("D5DuLP")},{}],G9z0Bl:[function(t,n){function e(){var t=l.info=NREUM.info;if(t&&t.agent&&t.licenseKey&&t.applicationID&&p&&p.body){l.proto="https"===f.split(":")[0]||t.sslForHttp?"https://":"http://",i("mark",["onload",a()]);var n=p.createElement("script");n.src=l.proto+t.agent,p.body.appendChild(n)}}function r(){"complete"===p.readyState&&o()}function o(){i("mark",["domContent",a()])}function a(){return(new Date).getTime()}var i=t("handle"),u=window,p=u.document,s="addEventListener",c="attachEvent",f=(""+location).split("?")[0],l=n.exports={offset:a(),origin:f,features:[]};p[s]?(p[s]("DOMContentLoaded",o,!1),u[s]("load",e,!1)):(p[c]("onreadystatechange",r),u[c]("onload",e)),i("mark",["firstbyte",a()])},{handle:"D5DuLP"}],loader:[function(t,n){n.exports=t("G9z0Bl")},{}]},{},["G9z0Bl"]);</script>
  <title>Appraiser Events</title>
  <link data-turbolinks-track="true" href="/assets/application-d90aa6b607e1084c9802752503a4569f.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/application-63257f1821daa59804517c178ec3a2be.js"></script>
  <meta content="authenticity_token" name="csrf-param" />
<meta content="eV2KxHpxUoVW9QS8FWt6IaP8SJXoHoJPtYycJPUmVbU=" name="csrf-token" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <div class="container">

        <p class="notice"></p>

<form accept-charset="UTF-8" action="/users/sign_in" class="form-signin" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="eV2KxHpxUoVW9QS8FWt6IaP8SJXoHoJPtYycJPUmVbU=" /></div>

    <h2 class="form-signin-heading">Sign in</h2>



  <div><label for="user_email">Email</label><br />
  <input autofocus="autofocus" class="form-control" id="user_email" name="user[email]" type="email" value="" /></div>

  <div><label for="user_password">Password</label><br />
  <input class="form-control" id="user_password" name="user[password]" type="password" /></div>

    <div><input name="user[remember_me]" type="hidden" value="0" /><input class="form-control" id="user_remember_me" name="user[remember_me]" type="checkbox" value="1" /> <label for="user_remember_me">Remember me</label></div>

  <div><input class="btn btn-lg btn-primary btn-block" name="commit" type="submit" value="Sign in" /></div>

  <input name="authenticity_token" type="hidden" value="eV2KxHpxUoVW9QS8FWt6IaP8SJXoHoJPtYycJPUmVbU="/>



  <a href="/users/password/new">Forgot your password?</a><br />




</form>


        </div>
    </body>
   </html>

1 个答案:

答案 0 :(得分:1)

请你分享一下你的表格吗?这似乎是真实性令牌的问题。

您可以尝试在表单选项中添加令牌:

<%= form_tag ..., authenticity_token: true do %>

在你的情况下:

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), authenticity_token: true, :html => {:class => "form-signin"}) do |f| %>