2022-07-25 19:31:54 -04:00
|
|
|
defmodule Memex.Accounts.UserNotifier do
|
2022-01-22 20:44:38 -05:00
|
|
|
@moduledoc """
|
|
|
|
Contains templates and messages for user messages
|
|
|
|
"""
|
|
|
|
|
2021-03-11 21:12:55 -05:00
|
|
|
# For simplicity, this module simply logs messages to the terminal.
|
|
|
|
# You should replace it by a proper email or notification tool, such as:
|
|
|
|
#
|
|
|
|
# * Swoosh - https://hexdocs.pm/swoosh
|
|
|
|
# * Bamboo - https://hexdocs.pm/bamboo
|
|
|
|
#
|
|
|
|
defp deliver(to, body) do
|
|
|
|
require Logger
|
|
|
|
Logger.debug(body)
|
|
|
|
{:ok, %{to: to, body: body}}
|
|
|
|
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
|