Class: UserNotify

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

Instance Method Summary collapse

Instance Method Details

#change_password(user, password, url = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/user_notify.rb', line 29

def change_password(user, password, url=nil)
  setup_email(user)

  # Email header info
  @subject += "Changed password notification"

  # Email body substitutions
  @body["name"] = "#{user.firstname} #{user.lastname}"
  @body["login"] = user.
  @body["password"] = password
  @body["url"] = url || LOGIN_ENGINE[:app_url].to_s
  @body["app_name"] = LOGIN_ENGINE[:app_name].to_s
end

#delete(user, url = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/user_notify.rb', line 56

def delete(user, url=nil)
  setup_email(user)

  # Email header info
  @subject += "Delete user notification"

  # Email body substitutions
  @body["name"] = "#{user.firstname} #{user.lastname}"
  @body["url"] = url || LOGIN_ENGINE[:app_url].to_s
  @body["app_name"] = LOGIN_ENGINE[:app_name].to_s
end

#forgot_password(user, url = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/user_notify.rb', line 16

def forgot_password(user, url=nil)
  setup_email(user)

  # Email header info
  @subject += "Forgotten password notification"

  # Email body substitutions
  @body["name"] = "#{user.firstname} #{user.lastname}"
  @body["login"] = user.
  @body["url"] = url || LOGIN_ENGINE[:app_url].to_s
  @body["app_name"] = LOGIN_ENGINE[:app_name].to_s
end

#pending_delete(user, url = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/user_notify.rb', line 43

def pending_delete(user, url=nil)
  setup_email(user)

  # Email header info
  @subject += "Delete user notification"

  # Email body substitutions
  @body["name"] = "#{user.firstname} #{user.lastname}"
  @body["url"] = url || LOGIN_ENGINE[:app_url].to_s
  @body["app_name"] = LOGIN_ENGINE[:app_name].to_s
  @body["days"] = LOGIN_ENGINE[:delayed_delete_days].to_s
end

#setup_email(user) ⇒ Object



68
69
70
71
72
73
74
# File 'app/models/user_notify.rb', line 68

def setup_email(user)
  @recipients = "#{user.email}"
  @from       = LOGIN_ENGINE[:email_from].to_s
  @subject    = "[#{LOGIN_ENGINE[:app_name]}] "
  @sent_on    = Time.now
  @headers['Content-Type'] = "text/plain; charset=#{LOGIN_ENGINE[:mail_charset]}; format=flowed"
end

#signup(user, password, url = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/models/user_notify.rb', line 2

def (user, password, url=nil)
  setup_email(user)

  # Email header info
  @subject += "Welcome to #{LOGIN_ENGINE[:app_name]}!"

  # Email body substitutions
  @body["name"] = "#{user.firstname} #{user.lastname}"
  @body["login"] = user.
  @body["password"] = password
  @body["url"] = url || LOGIN_ENGINE[:app_url].to_s
  @body["app_name"] = LOGIN_ENGINE[:app_name].to_s
end