设计软电子邮件确认

发布于 2024-11-06 04:03:14 字数 215 浏览 2 评论 0原文

我有一个使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅紫色的梦幻 2024-11-13 04:03:14

我相信你可以使用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.

流星番茄 2024-11-13 04:03:14

为已接受的答案添加更多细节。是的,您可以使用confirm_within,但是当您调用devise而不是devise_for时,您需要执行此操作。

class User
  devise :database_authenticatable, :encryptable, :confirmable, :rememberable,      :timeoutable, :lockable,
     :stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
     :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
end

上面的代码来自 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 not devise_for.

class User
  devise :database_authenticatable, :encryptable, :confirmable, :rememberable,      :timeoutable, :lockable,
     :stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
     :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
end

The above code comes from the models test for devise

You can also set the setting in the config/initializers/devise.rb file with config.confirm_within = 10.days

那一片橙海, 2024-11-13 04:03:14

嗯,我认为正确的标志是 allow_unconfirmed_access_for

config.allow_unconfirmed_access_for = 5.days

confirm_within 只是指定通过电子邮件发送的令牌的有效时间。

更多来自 config/initializers/devise.rb 的内容:

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

# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days

Hmm, I think the correct flag would be allow_unconfirmed_access_for:

config.allow_unconfirmed_access_for = 5.days

confirm_within just specifies how long the emailed token is good for.

More from config/initializers/devise.rb:

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

# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文