作为安全措施,我想将设备配置为在用户更改密码时发送确认电子邮件。如果可能的话,我宁愿重新使用我的设计邮件。任何想法如何做到这一点?
最佳答案
未经测试,但我会尝试使用简单的 after_update
回调在您的 User
模型中执行此操作:
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
关于ruby-on-rails - 使用设备发送密码更改确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15258838/