Class: PasswordMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/models/password_mailer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handle_user_password_reset_requested!(event) ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/models/password_mailer.rb', line 3

def handle_user_password_reset_requested!(event)
  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
  ).deliver_now
end

.handle_user_password_updated!(event) ⇒ Object



12
13
14
15
16
17
# File 'app/models/password_mailer.rb', line 12

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

Instance Method Details

#reset_password_email(attributes = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'app/models/password_mailer.rb', line 26

def reset_password_email(attributes = {})
  @user = attributes[:user]
  @reset_link = attributes[:reset_link]
  @token = attributes[:token]
  mail({
    to: attributes[:user].email,
    from: attributes[:from],
    subject: "Forgotten Password",
  })
end

#updated_password_email(attributes = {}) ⇒ Object



37
38
39
40
41
42
43
44
# File 'app/models/password_mailer.rb', line 37

def updated_password_email(attributes = {})
  @user = attributes[:user]
  mail({
    to: attributes[:user].email,
    from: attributes[:from],
    subject: "Password Updated",
  })
end