2

我想将设计配置为在用户更改密码时发送确认电子邮件作为安全措施。如果可能的话,我更愿意重复使用我的设计邮件。任何想法如何做到这一点?

4

2 回答 2

1

未经测试,但我会尝试在您的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
于 2013-03-06T23:06:37.843 回答
0

我会配置更新用户操作,您可以在他们的文档中阅读如何执行此操作。检查设计如何在注册操作中处理新注册用户的确认,并在新的重置密码操作中重新使用该代码。

于 2013-03-06T22:07:52.020 回答