Sha256: 18abd71fba57655c64f31ce09fbc042c004c36a0948f2eada77b45522e6f4163

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require "login/mail_config"

class PasswordMailer < ActionMailer::Base
  include Login::MailConfig

  class << self
    def handle_user_password_reset_requested!(event)
      deliver_reset_password_email(
        :user => event.object, 
        :from => site(event.source.site).email_from,
        :reset_link => password_reset_link(event.source, event.token), 
        :token => event.token
      )
    end

    def handle_user_password_updated!(event)
      deliver_updated_password_email(
        :user => event.object, 
        :from => site(event.source.site).email_from
      )
    end

    private

      def password_reset_link(controller, token)
        controller.send(:url_for, :action => 'edit', :token => token)
      end
  end
  
  def reset_password_email(attributes = {})
    recipients attributes[:user].email
    from       attributes[:from]
    subject    I18n.t(:'adva.passwords.notifications.reset_password.subject')
    body       attributes
  end

  def updated_password_email(attributes = {})
    recipients attributes[:user].email
    from       attributes[:from]
    subject    I18n.t(:'adva.passwords.notifications.password_updated.subject')
    body       attributes
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
adva_user-0.0.1 app/models/password_mailer.rb
adva-0.0.1 adva_user/app/models/password_mailer.rb