我需要设计将reset_password_token传回验证错误的视图。
现在,如果验证失败,则转到:/customers/password
,它会丢失?reset_password_token=foobar
这是我的模特:
devise :database_authenticatable, :registerable, :recoverable, :validatable,
:rememberable, :trackable, :authentication_keys => [:email, :storefront_id],
:reset_password_keys => [:email, :storefront_id]
这是来自视图中的表单操作:
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
这些是路线:
customer_password POST /:subdomain/customers/password(.:format) customer_passwords#create
new_customer_password GET /:subdomain/customers/password/new(.:format) customer_passwords#new
edit_customer_password GET /:subdomain/customers/password/edit(.:format) customer_passwords#edit
PUT /:subdomain/customers/password(.:format) customer_passwords#update
答案 0 :(得分:0)
这是因为表单提交执行了POST请求,并且所有属性都在请求消息正文中传递。
并且:当您提交表单时,reset_password_token存储在隐藏字段中。 https://github.com/plataformatec/devise/blob/master/app/views/devise/passwords/edit.html.erb