【问题标题】:send password change confirmation with devise使用设备发送密码更改确认
【发布时间】:2013-03-06 21:54:16
【问题描述】:

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

【问题讨论】:

    标签: ruby-on-rails ruby devise


    【解决方案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
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 我不是在询问重置密码,我是在询问用户更改密码后是否发送确认电子邮件。
      • 我更新了我的答案,无论哪种方式,它都是相同的方法。您自定义更新用户操作并添加邮件程序。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      • 2012-07-19
      • 2020-12-17
      • 1970-01-01
      • 1970-01-01
      • 2011-12-23
      相关资源
      最近更新 更多