ruby-on-rails - 使用设备发送密码更改确认

标签 ruby-on-rails ruby devise

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

最佳答案

未经测试,但我会尝试使用简单的 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/

相关文章:

ruby-on-rails - Rails delay_job以HTML格式发送电子邮件

javascript - rails : Paperclip gem no longer works after switching computers

html - 在 ruby​​ cgi 中更改 html 属性

ruby-on-rails - 为 Rails 上的连接、限制、选择等(不是条件)的 SQL 片段安全地转义字符串

mysql - rails : bundle doesn't show installed mysql2 gem

ruby-on-rails - RSpec 共享示例不得共享

ruby - 如何从模块中定义的类扩展 ruby​​ 类?

android - 具有设计和门卫的 Rails 4 API - Android 应用程序身份验证

ruby-on-rails - 现在 Rails : Compare DateTime with Time.

ruby-on-rails - 未初始化的常量 devise::controllers::internalhelpers