【发布时间】:2013-03-06 21:54:16
【问题描述】:
我想将设计配置为在用户更改密码时发送确认电子邮件作为安全措施。如果可能的话,我更愿意重复使用我的设计邮件。任何想法如何做到这一点?
【问题讨论】:
标签: ruby-on-rails ruby devise
我想将设计配置为在用户更改密码时发送确认电子邮件作为安全措施。如果可能的话,我更愿意重复使用我的设计邮件。任何想法如何做到这一点?
【问题讨论】:
标签: ruby-on-rails ruby devise
未经测试,但我会尝试在您的User 模型中使用简单的after_update 回调:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable # whatever
after_update :send_password_changed_notification
# attr_accessible, validations, ...
private
def send_password_changed_notification
# Send email with the mailer of your choice,
# e. g. your existing custom Devise mailer:
YourDeviseMailer.password_changed_notification(self).deliver if password_changed?
end
end
【讨论】:
我会配置更新用户操作,您可以在他们的documentation 中了解如何执行此操作。检查设计如何在注册操作中处理新注册用户的确认,并在新的重置密码操作中重新使用该代码。
【讨论】: