【发布时间】:2011-09-13 15:27:49
【问题描述】:
我刚刚开始使用 Devise。我有一个:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
我已将我的注册视图更改为:
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><%= f.email_field :email %></div>
<div><%= f.label :password %><%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><%= f.password_field :password_confirmation %></div>
<div><%= f.label :contact_me %><%= f.check_box :contact_me %></div>
<div><%= f.label :remember_me %><%= f.check_box :remember_me %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
但是,检查 POST 响应,无论我是否勾选“记住我”,我都可以在注册后看到 Cookie: 中设置的 remember_user_token。任何人都知道这是为什么,以及如何阻止它?
相比之下,签名 in 仅在选中该框时才设置该 cookie,正如预期的那样。
【问题讨论】:
-
你解决过这个问题吗?
-
@Ashitaka - 实际上我不确定。有时间我会试着给你检查一下。不过,可能不会那么快。