1

我在我的应用程序中使用 Devise 进行身份验证。我不想在用户注册时要求电子邮件确认,但如果用户希望应用程序向他们发送电子邮件更新,我确实需要它。这可以通过设计的内置 :confirmable 功能实现吗?我找到了设置用户无需确认即可登录多长时间的设置,但我基本上想将其设置为“永远”。

4

2 回答 2

1

查看https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb。您可能可以confirmation_period_valid?通过返回 always来覆盖true

或者,也许您可​​以将您的设置更改为类似10000.years.from_now,这对于“永远”来说可能是一个足够好的估计,也许?

于 2012-10-13T03:36:55.817 回答
0

寻找config/initializers/devise.rb_

  # ==> Configuration for :confirmable
  # A period that the user is allowed to access the website even without
  # confirming their account. For instance, if set to 2.days, the user will be
  # able to access the website for two days without confirming their account,
  # access will be blocked just in the third day. Default is 0.days, meaning
  # the user cannot access the website without confirming their account.
  # config.allow_unconfirmed_access_for = 2.days

将其设置为 1000.years。然后在您的email_updates方法中,调用#confirmed?以测试用户是否已确认其帐户。如果没有,请将它们发送到页面以重新发送确认链接,因为它现在可能已经过期。

于 2017-04-15T18:46:27.130 回答