设计软电子邮件确认
我有一个使用 Devise 和可确认模块的 Rails 3 应用程序。然而,阻止新注册用户在确认其电子邮件之前访问该网站会导致保留问题。相反,我们希望立即向用户授予访问权限,并且仍然向他们发送确认电子邮件。然后,我们将运行后台任务来锁定在固定时间内未确认电子邮件的用户。
这可以通过可确认模块实现吗?有没有办法仍然创建尚未使用可确认模块确认电子邮件的活动资源(用户)?关于实施这一点有什么一般建议吗?
I have a rails 3 application that uses Devise and the confirmable module. However, preventing newly registered users from accessing the the site until they confirm their email is causing retention problems. Instead, we would like to instantly grant access to the user and still send them a confirmation email. We would then run a background task to lock out user's who have not confirmed their email within a fixed period of time.
Is this possible with the confirmable module? Is there a way to still create an active resource (user) who hasn't confirmed their email with the confirmable module? Any general advice on implementing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信你可以使用confirm_within来指定锁定约束。您可以在调用 devise_for 时启用此功能。
http://rubydoc.info/github/plataformatec/devise/master/Devise /Models/Confirmable
另外,您可以通过检查已确认的?您的用户模型的状态。您可以在控制器中或使用 CanCan 或其他方式执行此操作。您网站上的某些任务可能不需要确认;当用户与其他人交互或可以使用您的网站发送某些通知/电子邮件等时,您可能更需要此功能。
I believe you can use confirm_within to specify a lockout constraint. You can enable this when you call devise_for.
http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable
Also, you can choose to constrain certain behaviors "only" to confirmed users by checking the confirmed? status of your user model. You could do this in the controller, or using CanCan, or whatever. Some tasks on your site probably don't require confirmation; you probably need this more when the user interacts with other people or can use your site to send certain notifications/emails, etc.
为已接受的答案添加更多细节。是的,您可以使用confirm_within,但是当您调用
devise
而不是devise_for
时,您需要执行此操作。上面的代码来自 devise 的模型测试,
您还可以在 config/initializers/devise.rb 文件中使用 config.confirm_within = 10.days 进行设置
To add a litte more detail to the accepted answer. Yes, you can use confirm_within but you need to do this when you call
devise
notdevise_for
.The above code comes from the models test for devise
You can also set the setting in the
config/initializers/devise.rb
file withconfig.confirm_within = 10.days
嗯,我认为正确的标志是
allow_unconfirmed_access_for
:confirm_within
只是指定通过电子邮件发送的令牌的有效时间。更多来自 config/initializers/devise.rb 的内容:
Hmm, I think the correct flag would be
allow_unconfirmed_access_for
:confirm_within
just specifies how long the emailed token is good for.More from
config/initializers/devise.rb
: