不要求用户使用 Devise 确认电子邮件
我在 Rails 3 (3.0.5) 项目中使用 Devise。我想使用可确认模块来允许用户确认他们的电子邮件地址,但是如果他们不确认,我不想阻止他们。
我目前已经通过设置(在 devise.rb 中)来完成此操作,
config.confirm_within = 100.years
有更好的方法吗?
I'm using Devise in a Rails 3 (3.0.5) project. I want to use the confirmable module to allow users to confirm their email address, however I don't want to block them if they do not confirm.
I have currently done this by setting (in devise.rb)
config.confirm_within = 100.years
Is there a nicer way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上在新版本的 devise 中
,我认为这是一个不错的解决方案
actually in newer versions of devise its
And in my opinion it's an alright solution
您现在可以将 config.allow_unconfirmed_access_for 设置为 nil 以无限期地允许未经确认的登录,同时仍请求确认。
https://github.com/plataformatec/devise/pull/2278
https://github.com/plataformatec/devise/blob/master /lib/devise.rb#L142
You can now set config.allow_unconfirmed_access_for to nil to allow unconfirmed logins indefinitely whilst still requesting confirmation.
https://github.com/plataformatec/devise/pull/2278
https://github.com/plataformatec/devise/blob/master/lib/devise.rb#L142
抱歉,但我真的想问一下,如果你无论如何都要让他们进来,为什么还要使用可确认模块?如果让人溜过去,确认模块能带来什么价值?
您也可以在创建操作中输入
user.confirm!
,这样您就不必设置100.years
值Sorry, but I really have to ask why you are using the confirmable module if you are just gonna let them in anyway? What value does the confirmation module bring if you let people slip by?
You might as well say
user.confirm!
within the create action so you don't have to set a value of100.years