Module: MnoEnterprise::Concerns::Mailers::SystemNotificationMailer

Extended by:
ActiveSupport::Concern
Included in:
SystemNotificationMailer
Defined in:
lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb

Instance Method Summary collapse

Instance Method Details

#confirmation_instructions(record, token, opts = {}) ⇒ Object

> Devise Email

Description:

New user: Email asking users to confirm their email
  OR
Existing user: 
 - Email asking users (on their new email) to confirm their email change
 - Email notifying users (on their old email) of an email change

Mandrill vars:

:first_name
:last_name
:full_name
:confirmation_link


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 38

def confirmation_instructions(record, token, opts={})
  update_email = record.confirmed? && record.unconfirmed_email?
  template = update_email ? 'reconfirmation-instructions' : 'confirmation-instructions'
  email = update_email ? record.unconfirmed_email : record.email
  MnoEnterprise::MailClient.deliver(template,
    default_sender,
    recipient(record).merge(email: email),
    user_vars(record).merge(confirmation_link: user_confirmation_url(confirmation_token: token))
  )
  if update_email
    MnoEnterprise::MailClient.deliver('email-change',
       default_sender,
       recipient(record),
       user_vars(record).merge(unconfirmed_email: record.unconfirmed_email)
    )
  end
end

#default_senderObject

Default email sender Override to allow dynamic sender



20
21
22
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 20

def default_sender
  DEFAULT_SENDER
end

#deletion_request_instructions(record, deletion_request) ⇒ Object

Description:

Email providing instructions + link to initiate the account termination
process.

Mandrill vars:

:first_name
:last_name
:full_name
:terminate_account_link


144
145
146
147
148
149
150
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 144

def deletion_request_instructions(record, deletion_request)
  MnoEnterprise::MailClient.deliver('deletion-request-instructions',
    default_sender,
    recipient(record),
    user_vars(record).merge(terminate_account_link: deletion_request_url(deletion_request))
  )
end

#organization_invite(org_invite) ⇒ Object

Description:

Send an email inviting the user to join an existing organization. If the user
is already confirmed it is directed to the organization invite page where he
can accept or decline the invite
If the user is not confirmed yet then it is considered a new user and will be directed
to the confirmation page

Mandrill vars:

:organization
:team
:ref_first_name
:ref_last_name
:ref_full_name
:ref_email
:invitee_first_name
:invitee_last_name
:invitee_full_name
:invitee_email
:confirmation_link


123
124
125
126
127
128
129
130
131
132
133
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 123

def organization_invite(org_invite)
  new_user = !org_invite.user.confirmed?
  confirmation_link = new_user ? user_confirmation_url(confirmation_token: org_invite.user.confirmation_token) : org_invite_url(org_invite, token: org_invite.token)
  email_template = new_user ? 'organization-invite-new-user' : existing_user_template(org_invite)

  MnoEnterprise::MailClient.deliver(email_template,
    default_sender,
    recipient(org_invite.user,new_user),
    invite_vars(org_invite,new_user).merge(confirmation_link: confirmation_link)
  )
end

#password_change(record, opts = {}) ⇒ Object

Description:

Email notifying a change of password


95
96
97
98
99
100
101
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 95

def password_change(record, opts={})
  MnoEnterprise::MailClient.deliver('password-change',
    default_sender,
    recipient(record),
    user_vars(record)
  )
end

#registration_instructions(email) ⇒ Object

Description:

Email providing registration instructions

Variables:

:registration_link


157
158
159
160
161
162
163
164
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 157

def registration_instructions(email)
  MnoEnterprise::MailClient.deliver(
    'registration-instructions',
    default_sender,
    {email: email},
    {registration_link: new_user_registration_url}
  )
end

#reset_password_instructions(record, token, opts = {}) ⇒ Object

> Devise Email

Description:

Email providing instructions + link to reset password

Mandrill vars:

:first_name
:last_name
:full_name
:reset_password_link


66
67
68
69
70
71
72
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 66

def reset_password_instructions(record, token, opts={})
  MnoEnterprise::MailClient.deliver('reset-password-instructions',
    default_sender,
    recipient(record),
    user_vars(record).merge(reset_password_link: edit_user_password_url(reset_password_token: token))
  )
end

#unlock_instructions(record, token, opts = {}) ⇒ Object

> Devise Email

Description:

Email providing instructions + link to unlock a user account after too many failed attempts

Mandrill vars:

:first_name
:last_name
:full_name
:unlock_link


84
85
86
87
88
89
90
# File 'lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb', line 84

def unlock_instructions(record, token, opts={})
  MnoEnterprise::MailClient.deliver('unlock-instructions',
    default_sender,
    recipient(record),
    user_vars(record).merge(unlock_link: user_unlock_url(unlock_token: token))
  )
end