使用Devise将可确认模块添加到现有站点

7
我正在为一个网络应用程序使用Devise,并希望在网站上添加confirmable模块。然而,由于未生成confirmation_token,用户无法登录。当单击“没有收到确认说明?”链接时,令牌仍未生成。
确认电子邮件只会生成此链接(请注意URL中缺少标记):
<p><a href="http://localhost:3000/users/confirmation">Confirm my account</a></p>

最好的方法是让它正常工作是什么?

非常感谢,
托尼

1个回答

9

我正在寻找相同的答案。我怀疑答案可能是数据模型包括每个用户是否已确认。它似乎添加了:

confirmation_token、confirmed_at、confirmation_sent_at

此外,confirmable模块似乎添加了这些方法:

:confirmation_token、:confirmation_token=、:confirmation_token?、 :confirmation_token_change、:confirmation_token_changed?、 :confirmation_token_was、:reset_confirmation_token!、:confirmed_at、 :confirmed_at=、:confirmed_at?、:confirmed_at_change、 :confirmed_at_changed?、:confirmed_at_was、:reset_confirmed_at!、 :confirmation_sent_at、:confirmation_sent_at=、:confirmation_sent_at?、 :confirmation_sent_at_change、:confirmation_sent_at_changed?、 :confirmation_sent_at_was、:reset_confirmation_sent_at!

因此,您可以在数据模型层中完成它。我正在使用Mongoid,所以我只需编写一个脚本,将每个用户的confirmed_at更改为今天。


1
这个问题显然会在 Devise 1.0.8 中得到修复。幸运的是,我只需要在一个暂存服务器上对一小部分用户进行操作。感谢您的答案和帮助! - slythic

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接