2020-12-15 14:24:14 +01:00
|
|
|
defmodule RecycledCloud.Accounts.UserNotifier do
|
2021-01-12 10:06:05 +01:00
|
|
|
alias RecycledCloud.Mailer
|
|
|
|
import Bamboo.Email
|
|
|
|
|
2020-12-15 14:24:14 +01:00
|
|
|
defp deliver(to, body) do
|
2021-01-12 16:25:27 +01:00
|
|
|
_msg = Mailer.template()
|
2021-01-12 10:06:05 +01:00
|
|
|
|> to(to)
|
|
|
|
|> subject("Recycled Cloud User Management Notification")
|
|
|
|
|> text_body(body)
|
|
|
|
|> Mailer.deliver_now()
|
|
|
|
|
2021-01-12 16:25:27 +01:00
|
|
|
{:ok, %{to: to, body: body}}
|
2020-12-15 14:24:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Deliver instructions to confirm account.
|
|
|
|
"""
|
|
|
|
def deliver_confirmation_instructions(user, url) do
|
|
|
|
deliver(user.email, """
|
|
|
|
|
|
|
|
==============================
|
|
|
|
|
|
|
|
Hi #{user.email},
|
|
|
|
|
|
|
|
You can confirm your account by visiting the URL below:
|
|
|
|
|
|
|
|
#{url}
|
|
|
|
|
|
|
|
If you didn't create an account with us, please ignore this.
|
|
|
|
|
|
|
|
==============================
|
|
|
|
""")
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Deliver instructions to reset a user password.
|
|
|
|
"""
|
|
|
|
def deliver_reset_password_instructions(user, url) do
|
|
|
|
deliver(user.email, """
|
|
|
|
|
|
|
|
==============================
|
|
|
|
|
|
|
|
Hi #{user.email},
|
|
|
|
|
|
|
|
You can reset your password by visiting the URL below:
|
|
|
|
|
|
|
|
#{url}
|
|
|
|
|
|
|
|
If you didn't request this change, please ignore this.
|
|
|
|
|
|
|
|
==============================
|
|
|
|
""")
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Deliver instructions to update a user email.
|
|
|
|
"""
|
|
|
|
def deliver_update_email_instructions(user, url) do
|
|
|
|
deliver(user.email, """
|
|
|
|
|
|
|
|
==============================
|
|
|
|
|
|
|
|
Hi #{user.email},
|
|
|
|
|
|
|
|
You can change your email by visiting the URL below:
|
|
|
|
|
|
|
|
#{url}
|
|
|
|
|
|
|
|
If you didn't request this change, please ignore this.
|
|
|
|
|
|
|
|
==============================
|
|
|
|
""")
|
|
|
|
end
|
|
|
|
end
|